Re: Bug in storing Timestamp
От | mikael-aronsson |
---|---|
Тема | Re: Bug in storing Timestamp |
Дата | |
Msg-id | 008901c53ea6$d955f6b0$8ba7e551@w128mtec обсуждение исходный текст |
Ответ на | Bug in storing Timestamp (Boris Kirzner <borisk@mainsoft.com>) |
Ответы |
Re: Bug in storing Timestamp
|
Список | pgsql-jdbc |
Hi ! I have never had any problems with timestamps, if I remember correct the resolution gets worse when you get far away from 1900 or so, is it possible that using year 0001 gives that bad resolution maybe ? Mikael ----- Original Message ----- From: "Boris Kirzner" <borisk@mainsoft.com> To: <pgsql-jdbc@postgresql.org> Sent: Monday, April 11, 2005 2:39 PM Subject: [JDBC] Bug in storing Timestamp > 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 > > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly
В списке pgsql-jdbc по дате отправления: