pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Jowett <oliver@opencloud.com>
To: matthias.malsy@sme.de
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Daylight Safing Problem 2004-10-31 00:00:00 (UTC)
Date: Tue, 15 Feb 2005 11:14:07 +1300
Message-ID: <421122AF.9010602@opencloud.com> (raw)
In-Reply-To: <22997.193.128.157.68.1108396149.squirrel@morpheus.sme.de>
References: <22997.193.128.157.68.1108396149.squirrel@morpheus.sme.de>

matthias.malsy@sme.de wrote:

> Description:
> ------------
> I reduced my problem to a simple testcase just storing and loading a date
> from the database. The tescase fails for the time interval of
> 2004-10-31 00:00:00 to 01:00:00 (UTC). In order to stay ANSI conform,
> I use the 'timestamp [without timezone]' data type.
> - create table mdso_demo (id int, d timestamp)
> 
> Scenario:
> ---------
> I am storing sales data (containing sales date/time) in a database by
> ignoring the timezone in order to make it comparable across multiple
> timezones. The sales date is deliverd by a foreign system as a String
> and is parsed by an UTC-SimpleDateFormatter. After safing and loading,
> the date (and its milliseconds) differs by 1 hour.

> Output (running on CET/CEST): [...]

The problem is that the raw value stored in the database is "31 Oct 2004 
02:00:00" with no timezone information. There are two possible instants 
in time in the CET/CEST timezone that match this:

   (initially in CEST, UTC+02)
   31 Oct 2004 02:00:00 CEST == 00:00:00 UTC
   (at 3am, clocks go back an hour to 2am; now in CET, UTC+01)
   31 Oct 2004 02:00:00 CET  == 01:00:00 UTC

Java's date parser happens to pick the second case when given a raw "2am 
local time" value.

So this is not a driver bug, it is something of a design flaw in your 
schema, since "timestamp without time zone" cannot identify a unique 
instant in local time when daylight savings is involved.

-O



view thread (2+ messages)

Message-ID: <421122AF.9010602@opencloud.com>
Permalink:  ../421122AF.9010602@opencloud.com/
Also on:    postgresql.org/message-id/421122AF.9010602@opencloud.com

 · 

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: oliver@opencloud.com, matthias.malsy@sme.de
  Subject: Re: Daylight Safing Problem 2004-10-31 00:00:00 (UTC)
  In-Reply-To: <421122AF.9010602@opencloud.com>
  References: <22997.193.128.157.68.1108396149.squirrel@morpheus.sme.de> <421122AF.9010602@opencloud.com>

* 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