bryce4president
11-02-2007, 10:52 AM
our dates and times are stored as integer fields on the database. When I bring them in through an SQL resultSet I handle them with the following code...
Date ecldate = new SimpleDateFormat("yyyyMMddHHmmss").parse("00000000000000");
txtdate = ECL.getString("lodte");
txttime = ECL.getString("clentm");
if(txttime.length() < 6)
{
txttime = "0" + txttime;
}
txttimestamp = txtdate + txttime;
long inttxttimestamp = Long.parseLong(txttimestamp);
if(inttxttimestamp == 0)
{
txttimestamp = "20071201000000";
}
ecldate = new SimpleDateFormat("yyyyMMddHHmmss").parse(txttimestamp);
This works, and it formats the date, but I don't like the format its in. This is what it gives me...
Fri Oct 12 16:01:30 EDT 2007
I would like the format to be something like this...
October 12, 2007 4:01 PM
I can't seem to get my head around how this is done. I've tried to use a formatter and such, but I just don't understand it I guess...
Any help is appreciated.
Date ecldate = new SimpleDateFormat("yyyyMMddHHmmss").parse("00000000000000");
txtdate = ECL.getString("lodte");
txttime = ECL.getString("clentm");
if(txttime.length() < 6)
{
txttime = "0" + txttime;
}
txttimestamp = txtdate + txttime;
long inttxttimestamp = Long.parseLong(txttimestamp);
if(inttxttimestamp == 0)
{
txttimestamp = "20071201000000";
}
ecldate = new SimpleDateFormat("yyyyMMddHHmmss").parse(txttimestamp);
This works, and it formats the date, but I don't like the format its in. This is what it gives me...
Fri Oct 12 16:01:30 EDT 2007
I would like the format to be something like this...
October 12, 2007 4:01 PM
I can't seem to get my head around how this is done. I've tried to use a formatter and such, but I just don't understand it I guess...
Any help is appreciated.