Re: Confusion about JDBC + TIME WITHOUT TIME ZONE - Mailing list pgsql-jdbc

From Vladimir Sitnikov
Subject Re: Confusion about JDBC + TIME WITHOUT TIME ZONE
Date
Msg-id CAB=Je-FhbUaqzfgiqzjidpK+Qe46rHHu6drFwgT=6JK8rF3K0w@mail.gmail.com
Whole thread Raw
In response to Confusion about JDBC + TIME WITHOUT TIME ZONE  (Bill Moran <wmoran@potentialtech.com>)
List pgsql-jdbc
Bill>When I try to insert via JDBC, the time is always adjusted for the
Bill>JVM's time zone. This behavior seems wrong to me

Bill>// Java code:
Bill>preparedStatement.setTime(1, Time.valueOf("00:00:10"));

A no-brain answer is: you do not provide the time zone, thus the
driver uses "current time zone".
What's wrong with that?

Note: java.sql.Time does not store "dd, hh, mm" in a separate fields.
It always converts to "milliseconds since...", thus it is doomed to
run into timezones.

Have you tried org.postgresql.jdbc.PgPreparedStatement#setTime(int,
java.sql.Time, java.util.Calendar)?

Alternative solution would be to use java.time.LocalTime -- it could
be easier to reason about.

More specific example would help to tell if the behavior is expected or not.
Can you share that?

Vladimir


pgsql-jdbc by date:

Previous
From: Pavel Raiskup
Date:
Subject: Re: Merge pgjdbc-parent-poms project into pgjdbc please
Next
From: Pavel Raiskup
Date:
Subject: Re: Merge pgjdbc-parent-poms project into pgjdbc please