Thanks for your help.
I changed my timestamps to datetime instead. That allowed my driver to get
the datetime field as a Date object. Then I used your code, and now
everything works fine.
Funny why simple problems sometime cause the biggest problems.
Best regards
Mads
> -----Original Message-----
> From: Tim Endres [mailto:time@stripped]
> Sent: Sunday, March 05, 2000 9:28 PM
> To: Mads S?gaard; java@stripped
> Subject: Re: Formatting mysql timestamps the right way...
>
>
> > 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...
>
> tim.
> Tim Endres time@stripped
> ICE Engineering, Inc. http://www.trustice.com/
> "USENET - a slow moving self parody." - Peter Honeyman
>
>
> ---------------------------------------------------------------------
> Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
> posting. To request this thread, e-mail java-thread835@stripped
>
> To unsubscribe, send a message to the address shown in the
> List-Unsubscribe header of this message. If you cannot see it,
> e-mail java-unsubscribe@stripped instead.
>