Skip site navigation (1) Skip section navigation (2)

Re: JDBC Driver and timezones

From: Lew <noone(at)lewscanon(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: JDBC Driver and timezones
Date: 2010-05-19 15:33:30
Message-ID: ht10cb$vb2$1@news.albasani.net (view raw, whole thread or download thread mbox)
Thread:
Lists: pgsql-jdbc
Kris Jurka
>> I think the problem is that the Java specification for java.sql.Time
>> requires that the date portion be filled in with 1970-01-01. So when
>> trying to determine the zone shift to apply when printing it out, it is
>> checking with that date instead of today's date as you are expecting.
>>
>> When reading a timetz value in, we don't need to determine what the zone
>> shift is, it's explicit, so in this case we shift by the explicit DST
>> amount. When printing it back out, the original zone offset has been
>> discarded and we shift by the non-DST amount because the date 1970-01-01
>> doesn't use DST. I think we'd like to be able to override the
>> getTimezoneOffset value for the Time object, but there's no easy way to
>> do that without creating our own PgTime object.

On 05/19/2010 06:43 AM, John Lister wrote:
> Hi, I spotted an issue regarding Daylight savings and timezones a while
> ago that affected UK times so it may be possible that it does the same
> in German ones. From memory - essentially the driver uses the epoch date
> to work out DST which unfortunately coincides with a year (1970) when
> the UK temporarily changed its DST rules.

This issue came up in pgsql.interfaces.jdbc and it seemed worth bringing into 
the wider Java world since it's not Postgres-specific.  The problem is that 
java.sql.Time values are date-agnostic so might not reflect the intended DST 
offset when referencing times relevant to "now".

This might be worth a bug report, or perhaps the problem is intractable and 
requires the explicit workaround that the database folks find they must use. 
Perhaps the new date/time libraries will address this somehow.

Opinions or assessments?

-- 
Lew

In response to

pgsql-jdbc by date

Next:From: Craig RingerDate: 2010-05-20 03:49:53
Subject: Documentation improvements for PgJDBC
Previous:From: John ListerDate: 2010-05-19 10:43:52
Subject: Re: JDBC Driver and timezones

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group