Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jQqqy-0005kJ-S0 for pgsql-jdbc@arkaria.postgresql.org; Tue, 21 Apr 2020 11:14:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jQqqx-0002Rf-QY for pgsql-jdbc@arkaria.postgresql.org; Tue, 21 Apr 2020 11:14:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jQqqx-0002RY-Kr for pgsql-jdbc@lists.postgresql.org; Tue, 21 Apr 2020 11:14:11 +0000 Received: from smtp.procolix.com ([95.215.185.30]) by magus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jQqqu-0001G9-NA for pgsql-jdbc@lists.postgresql.org; Tue, 21 Apr 2020 11:14:11 +0000 Received: from localhost (localhost [127.0.0.1]) by smtp.procolix.com (Postfix) with ESMTP id 0C3E444812 for ; Tue, 21 Apr 2020 13:14:08 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at smtp.procolix.com Received: from smtp.procolix.com ([127.0.0.1]) by localhost (host436.procolix.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cKA5IpbIjR5E for ; Tue, 21 Apr 2020 13:14:07 +0200 (CEST) Received: from webmail.procolix.com (webmail.procolix.com [95.215.185.205]) (Authenticated sender: mark@lawinegevaar.nl) by smtp.procolix.com (Postfix) with ESMTPA id BE58D43AD4 for ; Tue, 21 Apr 2020 13:14:07 +0200 (CEST) MIME-Version: 1.0 Date: Tue, 21 Apr 2020 13:14:07 +0200 From: Mark Rotteveel To: pgsql-jdbc@lists.postgresql.org Subject: Re: JDBC and timetz again In-Reply-To: <6860997a-b05f-a06a-f70c-f819f97485c6@gmx.net> References: <6d5fd225f38fb98faa662a0b9f8980ec@lawinegevaar.nl> <6860997a-b05f-a06a-f70c-f819f97485c6@gmx.net> User-Agent: Roundcube Webmail/1.4.2 Message-ID: <68340b56fd7d35945d869c94866cbc1d@lawinegevaar.nl> X-Sender: mark@lawinegevaar.nl Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-04-21 12:28, Thomas Kellerer wrote: > Mark Rotteveel schrieb am 21.04.2020 um 11:02: >> Note that JDBC itself doesn't define support for java.sql.Time (or >> java.time.LocalTime) for time with time zone types (instead it maps >> to java.time.OffsetTime). > I know that JDBC doesn't support that (and I mentioned the thread were > that was discussed previously) but I would expect the driver to at > least return a value that is correct. > > The interesting thing is, that if I use ResultSet.getString() on that > column I do get the correct "value", e.g. the following: > > ResultSet rs = stmt.executeQuery("select current_time"); > rs.next(); > System.out.println("getString: " + rs.getString(1)); > System.out.println("getTime: " + rs.getTime(1)); > > will print (when run at 12:26:08): > > getString: 12:26:08.275455+02 > getTime: 11:26:08 > > So at some point the driver does get the correct time, but the > conversion to a java.sql.Time seems to lose one hour somewhere. To be clear, I haven't checked exactly what the PostgreSQL JDBC driver does, but I think that it has to do with this part of the awkward definition of `java.sql.Time`[1]: """ The date components should be set to the "zero epoch" value of January 1, 1970 and should not be accessed. """ Take 12:26:08 in Europe/Berlin, today (with DST) that is 10:26:08 UTC, take 10:26:08 UTC on 1970-01-01 and in Europe/Berlin it's 11:26:08. [1]: https://docs.oracle.com/en/java/javase/11/docs/api/java.sql/java/sql/Time.html