Inconsistency between timezones

From: Manoj Ganesan <manoj(dot)ganesan(at)gmail(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Inconsistency between timezones
Date: 2009-09-15 20:18:23
Message-ID: 4b7f2c670909151318r58681e8eo75ecb32259b4937c@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi,

I am confused about how the driver interprets (if at all it does) timezones
to and from the database. When I run the following queries directly on the
database, these are the results I receive:

query: select clock_timestamp() + interval '15 hours'
result: "2009-09-16 06:06:33.801-05"

query: select date_trunc('day', clock_timestamp() + interval '15 hours')
result: "2009-09-16 00:00:00-05"

The above are the values I would expect as well. However, when I run the
same two queries (immediately after) from Java (via the JDBC driver), these
are the results:

query: select clock_timestamp() + interval '15 hours'
result: "2009-09-16 06:08:44.751"

query: select date_trunc('day', clock_timestamp() + interval '15 hours')
result: "2009-09-15 19:00:00.0"

As you can see, the first query yields the *expected* results. However, the
second result seems to have seen some timezone conversion from GMT to
Central Time somewhere. I would assume that clock_timestamp() used inside a
function, or outside a function should show similar results. Replacing
clock_timestamp() with current_timestamp gives the same results. Am I
missing something here?

JDBC driver version: 8.1.404
Server version: 8.3

Thanks a bunch,
Manoj

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Oliver Jowett 2009-09-16 00:17:30 Re: Inconsistency between timezones
Previous Message Joseph Shraibman 2009-09-15 19:26:51 BUG #5058: [jdbc] Silent failure with executeUpdate()