pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedJDBC setTimestamp/getTimestamp
2+ messages / 2 participants
[nested] [flat]
* JDBC setTimestamp/getTimestamp
@ 2000-06-03 16:12 Nissim <nissim@nksystems.com>
0 siblings, 1 reply; 2+ messages in thread
From: Nissim @ 2000-06-03 16:12 UTC (permalink / raw)
To: pgsql-interfaces@hub.org
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?
Check if the string with the date value contains "." and then use a
different format string.
I think it would probably be better if the server always returned
"yyyy-MM-dd HH:mm:ss.SSSzzz" regardless of whether milliseconds were
specified in the Insert/Update.
-Nissim
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: JDBC setTimestamp/getTimestamp
@ 2000-06-05 10:34 Peter Mount <peter@retep.org.uk>
parent: Nissim <nissim@nksystems.com>
0 siblings, 0 replies; 2+ messages in thread
From: Peter Mount @ 2000-06-05 10:34 UTC (permalink / raw)
To: Nissim <nissim@nksystems.com>; +Cc: pgsql-interfaces@hub.org
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@retep.org.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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2000-06-05 10:34 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-06-03 16:12 JDBC setTimestamp/getTimestamp Nissim <nissim@nksystems.com>
2000-06-05 10:34 ` Peter Mount <peter@retep.org.uk>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox