Re: Confusion about JDBC + TIME WITHOUT TIME ZONE

Поиск
Список
Период
Сортировка
От Vladimir Sitnikov
Тема Re: Confusion about JDBC + TIME WITHOUT TIME ZONE
Дата
Msg-id CAB=Je-FhbUaqzfgiqzjidpK+Qe46rHHu6drFwgT=6JK8rF3K0w@mail.gmail.com
обсуждение исходный текст
Ответ на Confusion about JDBC + TIME WITHOUT TIME ZONE  (Bill Moran <wmoran@potentialtech.com>)
Список 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 по дате отправления:

Предыдущее
От: Pavel Raiskup
Дата:
Сообщение: Re: Merge pgjdbc-parent-poms project into pgjdbc please
Следующее
От: Pavel Raiskup
Дата:
Сообщение: Re: Merge pgjdbc-parent-poms project into pgjdbc please