Re: JDBC Driver and timezones

Поиск
Список
Период
Сортировка
От Thomas Kellerer
Тема Re: JDBC Driver and timezones
Дата
Msg-id ht06tl$ueh$1@dough.gmane.org
обсуждение исходный текст
Ответ на Re: JDBC Driver and timezones  (Kris Jurka <books@ejurka.com>)
Список pgsql-jdbc
Kris Jurka, 19.05.2010 09:27:
>> 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.
>

Thanks for the detailed answer.
For the time being I can workaround this by explicitely setting the timezone.

It might be worth mentioning in the driver's documentation though.

Regards
Thomas


В списке pgsql-jdbc по дате отправления:

Предыдущее
От: "Marc Mamin"
Дата:
Сообщение: Re: JDBC Driver and timezones
Следующее
От: "John Lister"
Дата:
Сообщение: Re: JDBC Driver and timezones