Re: Timezones and time/timestamp values in FE/BE protocol

From: Rene Pijlman <rene(at)lab(dot)applinet(dot)nl>
To: Barry Lind <barry(at)xythos(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Timezones and time/timestamp values in FE/BE protocol
Date: 2001-09-09 21:43:36
Message-ID: kemnptkj287pr8odkra8d7c3d4qt9oseni@4ax.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-jdbc

On Sun, 09 Sep 2001 13:38:52 -0700, you wrote:
[...]
Thanks for your explanation. This helps a lot.

>If you could post a bit more about the issue you are having
>I might be able to be more specific.

I'm looking at the 4 remaining failures of our own JDBC test
suite. They all have to do with timestamps and times, and they
are all caused by a 1 hour shift between the expected value and
the actual value. I run both the backend and the JVM on the same
Linux test server.

Its located in Amsterdam, The Netherlands, Central European
Daylight Savings Time (CETDST, UTC+2, GMT+2). I always thought I
was in CET=GMT+1, but now the offset is 2, because of daylight
saving time (whoever invented that should be #!$^&). Perhaps I
should go live in Greenwich, they don't seem to have daylight
saving time overthere.

In psql I see:
show timezone;
NOTICE: Time zone is unset

Here is some detailed information about the failures. I'm
refering to line numbers in 7.2 current CVS:
TimeTest.java revision 1.1
TimestampTest.java revision 1.2

1) TimeTest.java:89

getHours(t) expected 1, actual 0
t.toString() returns the expected "01:02:03", but this is
because java.sql.Time.toString() converts to the JVM's timezone.

2) TimeTest.java:96

getHours(t) expected 23, actual 0
t.toString returns "00:59:59"

3) TimestampTest.java:115

Expected: getTimestamp(1970,6,2,8,13,0) returns "1970-06-02
08:13:00.0"
Actual: t.toString() returns "1970-06-02 09:13:00.0"

4) TimestampTest.java:115 (second time around)

Expected: getTimestamp(1970,6,2,8,13,0) returns "1970-06-02
08:13:00.0"
Actual: t.toString() returns "1970-06-02 07:13:00.0"

My first impression is that in all cases a timezone shift is
applied in only one direction (store vs. retrieve). The cause
might also be a problem with daylight saving time, there are
some comments about that in TimestampTest.java.

Up till now I've managed without a graphical debugger, but to
get a good feel for what's happening between the test code and
the wire I think it'll be easier to setup JBuilder with the
driver and step through the code.

But now its almost bedtime in my timezone, and you never know
with these mailing lists. Sometimes the solution is in your
inbox when you wake up :-)

Regards,
René Pijlman <rene(at)lab(dot)applinet(dot)nl>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2001-09-10 00:14:38 Re: [HACKERS] Troubles using German Umlauts with JDBC
Previous Message Jim Buttafuoco 2001-09-09 21:36:54 pg_dump -C and locations (with subject this time)

Browse pgsql-jdbc by date

  From Date Subject
Next Message Larry Rogers 2001-09-10 00:03:36 Something unusual has occured to cause the driver to fail. NullPointerException
Previous Message Barry Lind 2001-09-09 20:38:52 Re: Timezones and time/timestamp values in FE/BE protocol