Re: Two millisecond timestamp offset - Mailing list pgsql-jdbc

From Oliver Jowett
Subject Re: Two millisecond timestamp offset
Date
Msg-id 43219B60.2050706@opencloud.com
Whole thread Raw
In response to Two millisecond timestamp offset  (Adrian Cox <adrian@humboldt.co.uk>)
Responses Re: Two millisecond timestamp offset  (Adrian Cox <adrian@humboldt.co.uk>)
List pgsql-jdbc
Adrian Cox wrote:

> The output from Java code is:
> Result 1 :- 2005-05-12 17:14:21.000
> Result 2 :- 2004-11-10 17:32:19.002
>
> The database sees:
> testcode=> select * from test;
>  index |          datetime
> -------+----------------------------
>      1 | 2005-05-12 17:14:20.998+00
>      2 | 2004-11-10 17:32:19+00
> (2 rows)

This works correctly on my system, so there is something else going on here.

What is the JVM's default timezone? If you format the Date objects using
that timezone, what do you get?

The JDBC driver will use the JVM's default timezone to format dates
unless you explicitly pass a Calendar to setTimestamp() etc, so if that
timezone is mysteriously 2ms out then it'd explain the strange behaviour
you see.

-O

pgsql-jdbc by date:

Previous
From: Adrian Cox
Date:
Subject: Two millisecond timestamp offset
Next
From: Adrian Cox
Date:
Subject: Re: Two millisecond timestamp offset