Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id CDA4B632967 for ; Sun, 3 May 2009 07:41:08 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 11806-06 for ; Sun, 3 May 2009 07:41:07 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mk-filter-2-a-1.mail.uk.tiscali.com (mk-filter-2-a-1.mail.uk.tiscali.com [212.74.100.53]) by mail.postgresql.org (Postfix) with ESMTP id 7AD2C6323F0 for ; Sun, 3 May 2009 07:41:07 -0300 (ADT) X-Trace: 192244604/mk-filter-2.mail.uk.tiscali.com/B2C/$b2c-THROTTLED-DYNAMIC/b2c-CUSTOMER-DYNAMIC-IP/62.64.158.120/None/john.lister-ps@kickstone.com X-SBRS: None X-RemoteIP: 62.64.158.120 X-IP-MAIL-FROM: john.lister-ps@kickstone.com X-SMTP-AUTH: X-MUA: Thunderbird 2.0.0.21 (Windows/20090302) X-IP-BHB: Once X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsECANcR/Uk+QJ54/2dsb2JhbAAIzAuDfQU X-IronPort-AV: E=Sophos;i="4.40,285,1238972400"; d="scan'208";a="192244604" Received: from 62-64-158-120.dynamic.dial.as9105.com (HELO [192.168.6.11]) ([62.64.158.120]) by smtp.tiscali.co.uk with ESMTP; 03 May 2009 11:41:05 +0100 Message-ID: <49FD74BF.7050003@kickstone.com> Date: Sun, 03 May 2009 11:41:03 +0100 From: John Lister User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) MIME-Version: 1.0 To: Oliver Jowett , pgsql-jdbc@postgresql.org Subject: Re: getTiIme/Timestamp with TimeZone inconsistency References: <49FC495F.1020302@kickstone.com> <49FCD8DB.7000707@opencloud.com> In-Reply-To: <49FCD8DB.7000707@opencloud.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200905/14 X-Sequence-Number: 19564 Oliver Jowett wrote: > John Lister wrote: > > >> 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? >> > > I believe this is necessary so that the Time type's invariants (that > day/month/year is Jan 1 1970 in the specified timezone) are satisfied. > The driver extends the interpretation of getTime(int,Calender) to mean > that the returned Time object will be valid for the specified Calendar, > regardless of whether a timezone was present in the underlying DB or not. > > The underlying timezone, if present, is still used when constructing a > milliseconds value, but the driver then rotates that resulting value > into the target timezone. If we don't do that then you get the strange > result that retrieving a time "01:35:42" while providing a Calendar will > result in a Time object that does not display as 01:35:42 if you format > it with that same Calendar. (I hesitate to say whether this is right or > wrong, because as usual JDBC is woefully underspecified in this area, > but it's certainly confusing at a minimum) > > -O > > I agree the JDBC spec is vague, but I read the spec such that the supplied calendar is *only* used if the server doesn't support a timezone. I think my main concern is that setTimestamp behaves differently to setTime. I'm not sure which is correct (i'd tend to the former) but i think they should behave the same... I'm not sure what the correct behaviour should be if the server has a timezone and you specify one to use. Hopefully the app writer would only use this case for none timezone columns/results.... maybe too much to ask for :) JOHN