Hi,

> The UTC time should always be the same no
> matter the Timezone used.

Well, and that's why it is problematic.

Let's say I'm currently in Switzerland, and store the timestamp
"1970-01-01 04:00:00" in the database. If the GMT/UTC value is stored
(GMT is basically UTC, at least in this context) then this is the long
value 10800000. So this value is stored in the database file.

Now the database file is opened on a computer in Australia. The value
10800000 is read from the database file, and displayed on the screen
as 1970-01-01 13:00:00.0.

Well, it's the same "time", of course. But it's kind of unexpected.
Specially if you happen to store things like a birthday. Suddenly a
person is born on another day...

Test case:

    TimeZone.setDefault(TimeZone.getTimeZone("Europe/Zurich"));
    long t = java.sql.Timestamp.valueOf("1970-01-01 04:00:00").getTime();
    System.out.println(t);
    TimeZone.setDefault(TimeZone.getTimeZone("Australia/Melbourne"));
    System.out.println(new java.sql.Timestamp(t).toString());

That's why H2 now uses the ZONE_OFFSET, but possibly this doesn't
always work correctly... I guess when the date stored is during the
daylight saving period (summertime). I will need to check. Maybe it
would be easier to store the actual string ("1970-01-01 04:00:00")
instead of a long...

Regards,
Thomas

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to