From: Samuel L. Bronkowitz <slb@keghouse.net>
To: pgsql-jdbc@postgresql.org
Subject: Fractional timezone bug + patch
Date: Thu, 26 May 2005 17:49:49 +0930
Message-ID: <20050526081949.GA98221@keghouse.net> (raw)
Hi. I'm in Adelaide, Australia, where the standard timezone is +9:30.
A couple of hours ago I stumbled across a JDBC bug when calling
getTimestamp() on a ResultSet: the fractional part of the timezone was
being dropped, so the returned timestamp was in +9. Therefore, when
displayed in the VM's timezone of +9:30, the timestamp had 30 minutes
tacked on and was thus 30 minutes into the future.
A perusal of the archives finds that a fractional timezone bug was
fixed in 2001, however a lot of the code seems to have been rewritten
between then and now.
A quick look over the driver source code found the bug: a simple
string-processing flaw. Two "sep = ..." and "end = ..." lines were in
the wrong order (see below), thus the code skipped past the ":" and
missed the fractional offset. A patch to the latest CVS is below.
- Samuel
inline patch 1: org/postgresql/jdbc2/TimestampUtils.java (+1/-1 lines) download inline-1.patch--- org/postgresql/jdbc2/TimestampUtils.java.orig 2005-02-15 19:01:47.000000000 +1030+++ org/postgresql/jdbc2/TimestampUtils.java 2005-05-26 17:37:43.000000000 +0930@@ -120,12 +120,12 @@
end = firstNonDigit(s, start);
int tzhr = number(s, start, end);
start = end + 1;
- end = firstNonDigit(s, start);
sep = charAt(s, end);
+ end = firstNonDigit(s, start);
int tzmin = 0;
if (sep == ':') {
tzmin = number(s, start, end);
start = end + 1;
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: slb@keghouse.net
Subject: Re: Fractional timezone bug + patch
In-Reply-To: <20050526081949.GA98221@keghouse.net>
References: <20050526081949.GA98221@keghouse.net>
* 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