Re: Timestamp problem

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Timestamp problem
Date: 2008-01-03 18:49:36
Message-ID: 477D2E40.4020105@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Peter Eisentraut wrote:

> Note,
> however, that this application does not use time zones or time-zone aware
> data types at all. It merely wishes to store '2007-03-25 02:30:00' and
> retrieve it in identical form.

getTimestamp() must convert the retrieved timestamp to *some* timezone
since Timestamp is only meaningful in a particular timezone. If you
don't pass an explicit Calendar, it uses the default JVM timezone. If
you want to avoid DST and similar you should explicitly pass a Calendar
object to Timestamp for a timezone that does not use daylight savings
(e.g. UTC) and use the same timezone to interpret the Timestamp.

The internal representation of java.sql.Timestamp (which is out our
control) is seconds-since-epoch, so you simply can't represent all
possible times-without-timezone if you interpret that using rules from a
timezone with daylight savings. In your case there is no possible
seconds-since-epoch value that will represent '2007-03-25 02:30:00' in
your default timezone.

-O

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Albe Laurenz 2008-01-04 08:30:44 Re: JDBC driver class
Previous Message Tom Lane 2008-01-03 16:21:09 Re: Permissions problem