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

Re: JDBC Driver and timezones

From: Kris Jurka <books(at)ejurka(dot)com>
To: Thomas Kellerer <spam_eater(at)gmx(dot)net>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: JDBC Driver and timezones
Date: 2010-05-19 07:27:51
Message-ID: alpine.BSO.2.00.1005190257480.27053@leary.csoft.net (view raw or flat)
Thread:
Lists: pgsql-jdbc

On Wed, 19 May 2010, Thomas Kellerer wrote:

> System.out.println("DST active: " + TimeZone.getDefault().useDaylightTime());
> System.out.println("DST delta: " + TimeZone.getDefault().getDSTSavings());
>
> it correctly shows me that the JDK knows that DST is active and that it 
> should add one hour
> (without setting a timezone when starting the JVM)

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.

Kris Jurka

In response to

Responses

pgsql-jdbc by date

Next:From: Thomas KellererDate: 2010-05-19 08:19:15
Subject: Re: JDBC Driver and timezones
Previous:From: Marc MaminDate: 2010-05-19 07:18:42
Subject: Re: JDBC Driver and timezones

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