pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kris Jurka <books@ejurka.com>
To: Thomas Kellerer <spam_eater@gmx.net>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: JDBC Driver and timezones
Date: Wed, 19 May 2010 03:27:51 -0400 (EDT)
Message-ID: <alpine.BSO.2.00.1005190257480.27053@leary.csoft.net> (raw)
In-Reply-To: <ht01ae$9oq$1@dough.gmane.org>
References: <hstmm1$96v$1@dough.gmane.org>
	<e979a6b62190fc12d767b1aa28fb724e.squirrel@webmail.axn-software.de>
	<hsv2np$qhq$1@dough.gmane.org>
	<4BF32A15.8010502@opencloud.com>
	<hsvvp4$4lq$1@dough.gmane.org>
	<ht01ae$9oq$1@dough.gmane.org>



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



view thread (13+ messages)  latest in thread

Message-ID: <alpine.BSO.2.00.1005190257480.27053@leary.csoft.net>
Permalink:  ../alpine.BSO.2.00.1005190257480.27053@leary.csoft.net/
Also on:    postgresql.org/message-id/alpine.BSO.2.00.1005190257480.27053@leary.csoft.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: books@ejurka.com, spam_eater@gmx.net
  Subject: Re: JDBC Driver and timezones
  In-Reply-To: <alpine.BSO.2.00.1005190257480.27053@leary.csoft.net>
  References: <hstmm1$96v$1@dough.gmane.org> <e979a6b62190fc12d767b1aa28fb724e.squirrel@webmail.axn-software.de> <hsv2np$qhq$1@dough.gmane.org> <4BF32A15.8010502@opencloud.com> <hsvvp4$4lq$1@dough.gmane.org> <ht01ae$9oq$1@dough.gmane.org> <alpine.BSO.2.00.1005190257480.27053@leary.csoft.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox