Fractional timezone bug + patch

Поиск
Список
Период
Сортировка
От Samuel L. Bronkowitz
Тема Fractional timezone bug + patch
Дата
Msg-id 20050526081949.GA98221@keghouse.net
обсуждение исходный текст
Список pgsql-jdbc
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

--- 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;


В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Dave Cramer
Дата:
Сообщение: Re: BIGINT <-> java.lang.String auto cast
Следующее
От: Oliver Jowett
Дата:
Сообщение: Re: BIGINT <-> java.lang.String auto cast