From: | "mikael-aronsson" <mikael-aronsson(at)telia(dot)com> |
---|---|
To: | "Boris Kirzner" <borisk(at)mainsoft(dot)com>, <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Re: Bug in storing Timestamp |
Date: | 2005-04-11 14:57:57 |
Message-ID: | 008901c53ea6$d955f6b0$8ba7e551@w128mtec |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)mainsoft(dot)com>
To: <pgsql-jdbc(at)postgresql(dot)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(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2005-04-11 15:07:27 | Re: Bug in storing Timestamp |
Previous Message | Boris Kirzner | 2005-04-11 12:39:56 | Bug in storing Timestamp |