pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: mikael-aronsson <mikael-aronsson@telia.com>
To: Boris Kirzner <borisk@mainsoft.com>
To: pgsql-jdbc@postgresql.org
Subject: Re: Bug in storing Timestamp
Date: Mon, 11 Apr 2005 16:57:57 +0200
Message-ID: <008901c53ea6$d955f6b0$8ba7e551@w128mtec> (raw)
References: <425A701C.6070608@mainsoft.com>

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 




view thread (6+ messages)  latest in thread

Message-ID: <008901c53ea6$d955f6b0$8ba7e551@w128mtec>
Permalink:  ../008901c53ea6$d955f6b0$8ba7e551@w128mtec/
Also on:    postgresql.org/message-id/008901c53ea6$d955f6b0$8ba7e551@w128mtec

 · 

reply

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: mikael-aronsson@telia.com, borisk@mainsoft.com
  Subject: Re: Bug in storing Timestamp
  In-Reply-To: <008901c53ea6$d955f6b0$8ba7e551@w128mtec>
  References: <425A701C.6070608@mainsoft.com> <008901c53ea6$d955f6b0$8ba7e551@w128mtec>

* 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