This is a pretty simple matter, but it has caused me quite a few problems,
so please help me.
I'm having trouble formatting a date and time the right way. Could anyone
please post a snippet of code that formats a mysql timestamp into something
readable.
My suggestion is to use the driver's getDate() routine to get a java.sql.Date,
which is a subclass of java.util.Date. Then use SimpleDateFormat. For instance:
ResultSet rs = ...;
java.sql.Date sqlDate = rs.getDate(1);
SimpleDateFormat dFmt = new SimpleDateFormat( "MM/dd/yyyy hh:mm:ss z" );
FieldPosition pos = new FieldPosition(0);
StringBuffer fmtBuf = new StringBuffer();
dFmt.format( sqlDate, fmtBuf, pos );
// Now fmtBuf contains your formatted date and time...