getTiIme/Timestamp with TimeZone inconsistency - Mailing list pgsql-jdbc

From John Lister
Subject getTiIme/Timestamp with TimeZone inconsistency
Date
Msg-id 49FC495F.1020302@kickstone.com
Whole thread Raw
Responses Re: getTiIme/Timestamp with TimeZone inconsistency  (Oliver Jowett <oliver@opencloud.com>)
List pgsql-jdbc
Looking at getTime and getTimestamp in TimestampUtils as used by the
getTime(int, Calendar) and getTimestamp(int, Calendar) functions in
AbstractJDBC2ResultSet there seems to be an inconsistency:

The API docs for these state "This method uses the given calendar to
construct an appropriate millisecond value for the time if the
underlying database does not store timezone information. "

and in TimestampUtils .getTimestamp if the server returns a timezone, it
is used instead of the supplied calendar.

However in TimestampUtils.getTime, this is initially done, but then
reversed further down and the supplied timezone is used as follows:

        if (ts.hasDate) {
            // Rotate it into the requested timezone before we zero out
the date
            .....
            cal.setTime(new Date(useCal.getTime().getTime()));
            useCal = cal;
        }

is there a reason for this as it seems inconsistent with getTimestamp
and the api docs?

Removing this makes the unit test TimezoneTest.testTime more consistent
(the first group of tests all return the same value - instead of the
last one being negative)


I ask as i'm playing with the adding binary wire transfer and Mikko
Tiihonen original patch omitted time/dates as he reported they failed
the unit tests.


Thanks


pgsql-jdbc by date:

Previous
From: Adam B
Date:
Subject: Re: A basic Statement.getGeneratedKeys() implementation (patch attached)
Next
From: Oliver Jowett
Date:
Subject: Re: getTiIme/Timestamp with TimeZone inconsistency