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