Re: JDBC and timetz again
От | Mark Rotteveel |
---|---|
Тема | Re: JDBC and timetz again |
Дата | |
Msg-id | 6d5fd225f38fb98faa662a0b9f8980ec@lawinegevaar.nl обсуждение исходный текст |
Ответ на | JDBC and timetz again (Thomas Kellerer <shammat@gmx.net>) |
Ответы |
Re: JDBC and timetz again
|
Список | pgsql-jdbc |
On 2020-04-21 08:00, Thomas Kellerer wrote: > 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? Could it be it is using 1970-01-01 as a base date in a conversion somewhere, so its rebasing the time with DST to non-DST time? 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). Mark
В списке pgsql-jdbc по дате отправления: