From: Thomas Kellerer <shammat@gmx.net>
To: pgsql-jdbc@lists.postgresql.org
Subject: JDBC and timetz again
Date: Tue, 21 Apr 2020 08:00:48 +0200
Message-ID: <cb422c40-24c1-1e07-e516-360b8a609771@gmx.net> (raw)
Hello,
last year I asked[1] about not being able go use ResultSet.getObject(..., LocalTime.class) for columns defined as timetz.
This typically happens when using "current_time" in a SELECT statement.
So I decided to switch to ResultSet.getTime() for those columns. However, it turns out this doesn't work properly when DST is in effect.
Postgres runs locally on my laptop and my Windows is set to Europe/Berlin and to automatically adjust DST.
But when I run "SELECT current_time" at 10:00 ResultSet.getTime() returns 09:00.
I had a brief look at the source code, and it seems that the driver does try to adjust the time to the current TimeZone (as returned from Calendar). But still returning a time that is an hour off seems like a bug to me.
I managed to work around that, by adding the TimeZone.getRawOffset() to the time retrieved from the driver. But that seems wrong.
Any ideas?
Regards
Thomas
[1] https://www.postgresql.org/message-id/flat/q89m8j%2463i8%241%40blaine.gmane.org
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: shammat@gmx.net
Subject: Re: JDBC and timetz again
In-Reply-To: <cb422c40-24c1-1e07-e516-360b8a609771@gmx.net>
References: <cb422c40-24c1-1e07-e516-360b8a609771@gmx.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