[29616] in bugtraq
Re: Oracle JDBC: Inconsistent handling of timestamps
daemon@ATHENA.MIT.EDU (Peter J. Holzer)
Wed Apr 2 18:23:21 2003
Date: Wed, 2 Apr 2003 11:17:30 +0200
From: "Peter J. Holzer" <hjp@wsr.ac.at>
To: bugtraq@securityfocus.com
Message-ID: <20030402091730.GB8175@wsr.ac.at>
Mail-Followup-To: bugtraq@securityfocus.com
Mime-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-md5;
protocol="application/pgp-signature"; boundary="2B/JsCI69OhZNC5r"
Content-Disposition: inline
In-Reply-To: <20030331084805.GC29563@tivano.de>
--2B/JsCI69OhZNC5r
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
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=20
> 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 =3D new Timestamp(1067130000000L); // 26.10.03 02:0=
0 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.=20
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=20
"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
--=20
_ | Peter J. Holzer | Unser Universum w=E4re betr=FCblich
|_|_) | Sysadmin WSR / LUGA | unbedeutend, h=E4tte es nicht jeder
| | | hjp@wsr.ac.at | Generation neue Probleme bereit.
__/ | http://www.hjp.at/ | -- Seneca, naturales quaestiones
--2B/JsCI69OhZNC5r
Content-Type: application/pgp-signature
Content-Disposition: inline
-----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-----
--2B/JsCI69OhZNC5r--