Re: JDBC setTimestamp/getTimestamp

From: Peter Mount <peter(at)retep(dot)org(dot)uk>
To: Nissim <nissim(at)nksystems(dot)com>
Cc: pgsql-interfaces(at)hub(dot)org
Subject: Re: JDBC setTimestamp/getTimestamp
Date: 2000-06-05 10:34:44
Message-ID: Pine.LNX.4.10.10006051133580.5726-100000@maidast.retep.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

On Sat, 3 Jun 2000, Nissim wrote:

> Hi,
>
> if you do
>
> Calendar cal = Calendar.getInstance();
> cal.setTime( new java.util.Date() );
> stmt.setTimeStamp( 1, new java.sql.Timestamp( cal.getTime().getTime() )
> );
>
> where param 1 is a column with datatype timestamp.
>
> And then you do
>
> rset.getTimeStamp( 1 );
>
> to select the same column,
>
> you get an exception, because the setTimeStamp did a toString() on the
> java.sql.Timestamp, which returns "yyyy-mm-dd hh:mm:ss.fffffffff". Then
> the select statement will return something like this: "2000-06-03
> 11:47:47.85-04" and the getTimeStamp tries to shove thaat into a
> SimpleDateFormat initialized with this: "yyyy-MM-dd HH:mm:sszzz".
>
> Would the following be a bad way to fix this?

This was fixed in cvs last week.

--
Peter T Mount peter(at)retep(dot)org(dot)uk
Main Homepage: http://www.retep.org.uk
PostgreSQL JDBC Faq: http://www.retep.org.uk/postgres
Java PDF Generator: http://www.retep.org.uk/pdf

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Peter Mount 2000-06-05 10:48:17 Re: jdbc, applet -> servlet;corba ??
Previous Message Peter Mount 2000-06-05 10:31:02 Re: Re: Simple bug in JDBC interface