Bug in storing Timestamp - Mailing list pgsql-jdbc

From Boris Kirzner
Subject Bug in storing Timestamp
Date
Msg-id 425A701C.6070608@mainsoft.com
Whole thread Raw
Responses Re: Bug in storing Timestamp
List pgsql-jdbc
Short description :
Storing java.sql.Timestamp with specified milliseconds value results to
wrong value stored in db.

System details :
OS : WindowsXP
PostgreSQL version : 8.0.1
Driver version : 8.0 build 310

Detailed description :
In order to reproduce the bug run the following code.
Create the table in the db.
The code creates a timestamp of "0001-01-01 02:02:02.0" and stores it
into the db.
The actual value stored is "02:22:42".


CREATE TABLE TYPES_EXTENDED (
  id char(10),
  t_time time
)
WITHOUT OIDS;

long milliseconds = Timestamp.valueOf("0001-01-01 02:02:02.0").getTime();
Timestamp javaTimestamp = new Timestamp(milliseconds);
System.out.println("Timestamp stored : " + javaTimestamp);
PreparedStatement stmt = connection.prepareStatement("insert into
types_extended(ID,t_time) values ('aaa',?)");
stmt.setTimestamp(1, javaTimestamp);
stmt.execute();


Thank you in advance,

--
Boris Kirzner
Mainsoft Corporation
http://www.mainsoft.com


pgsql-jdbc by date:

Previous
From:
Date:
Subject: demo to use J2ME and Wireless Toolkit 2.2
Next
From: "mikael-aronsson"
Date:
Subject: Re: Bug in storing Timestamp