|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
Re: Oracle JDBC: Inconsistent handling of timestamps
From: Peter J. Holzer (hjp
wsr.ac.at)
Date: Wed Apr 02 2003 - 03:17:30 CST
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 2003-03-31 10:48:05 +0200, Peter Conrad wrote:
> Certain java.sql.Timestamp values aren't written to (or retrieved from)
> the database correctly. Timestamps affected are in the time interval just
> before switchover from DST to non-DST (the bug was noticed on
> October 27th 2002 for the first time, when the switchover from MET/DST to MET
> took place). Various timestamp values in the range
> 2:00 AM - 2:59:59 AM (MET/DST) on October 27th 2002 as well as on October
> 26th 2003 have been verified to reproduce the bug, with the database as
> well as the JDBC client running in MET.
[...]
> Timestamp problem = new Timestamp(1067130000000L); // 26.10.03 02:00 MET/DST
That's a general problem with daylight savings time. On the switch from
DST to standard time, one hour (02:00:00 .. 03:00:00 in the case of MET)
occurs twice. If a timestamp is stored in the local timezone but without
timezone information, this information is ambiguous.
This is not Oracle-specific but would happen with any database which
stores timestamps in "human readable" form without timezone information.
If you need to store unambiguous timestamps, use UTC or a numeric
"units since the epoch" format (like POSIX time_t or Java millis).
What's nasty about your sample code is that you specify the timestamp in
Java millis, but it isn't stored that way. It is easy for a programmer
to forget about the type conversion and possible loss of information.
hp
--
_ | Peter J. Holzer | Unser Universum wäre betrüblich
|_|_) | Sysadmin WSR / LUGA | unbedeutend, hätte es nicht jeder
| | | hjp
wsr.ac.at | Generation neue Probleme bereit.
__/ | http://www.hjp.at/ | -- Seneca, naturales quaestiones
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iQDQAwUBPoqqqlLjemazOuKpAQEqGgXRATcsvnvOaFx0VNOCfKWSJevGPcd8zcpC
TN/hmvPcJ34av0mfWgTINj3dJuX9QMHJewz7K90e/xHCoU6pDZ5tID8oUbZvvjlB
lyVs0Wnx1Q2XAKivrxRRZBpHQBRQle6fQbRLcLs8V1hV+SZqURdEMaogkN9BhKCD
qtj38aAAC0JulVSbjCdX41uKujNlv+MMeUMu/2PZXnOl4Rg7TVlwVTCRHsKqmzul
mGL0lv7WKHasEYzAEREBzs5lBA==
=R1lc
-----END PGP SIGNATURE-----
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]