Re: Daylight saving time question

From: Lew <noone(at)lwsc(dot)ehost-services(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Daylight saving time question
Date: 2009-05-23 19:18:21
Message-ID: gv9i5u$35v$1@news.albasani.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Bayless Kirtley wrote:
> Thanks Tom and Scott. You got me looking in the right direction. In this
> case
> the client and server are on the same machine (testing/development) and
> psql
> does return the right result. I tried all the possibilities from the
> java program,
> "show timezone", "select current_time" and "select current_timestamp".
> These
> were all JDBC queries. When I used result.getString(), the values looked
> right. When I used result.getTime(), they were off by one hour as if
> daylight saving were not in effect.

If 'result' is a Java 'java.util.Date' type (or one of its java.sql subtypes),
then it only holds milliseconds since epoch as if in GMT; 'Date' holds no
timezone information as such. In that situation, 'result.getTime()' returns a
'long' value.

How exactly are you displaying 'result.getTime()'? How exactly are you
determining that its value is "off" by one hour? Can you show us Java code?

> Is this a flaw in the JDBC driver or is that the expected behavior? In
> either case I do now have a workaround but would like to know.

It is not a flaw in the JDBC driver.

--
Lew

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2009-05-23 19:47:53 Re: Sql Update Sentence
Previous Message Havasvölgyi Ottó 2009-05-23 19:14:38 Re: 8.3: timestamp subtraction