From: Boris Kirzner <borisk@mainsoft.com>
To: pgsql-jdbc@postgresql.org
Subject: Bug in storing Timestamp
Date: Mon, 11 Apr 2005 15:39:56 +0300
Message-ID: <425A701C.6070608@mainsoft.com> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: borisk@mainsoft.com
Subject: Re: Bug in storing Timestamp
In-Reply-To: <425A701C.6070608@mainsoft.com>
References: <425A701C.6070608@mainsoft.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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