From: | Vladimir Sitnikov <sitnikov(dot)vladimir(at)gmail(dot)com> |
---|---|
To: | Bill Moran <wmoran(at)potentialtech(dot)com> |
Cc: | List <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Re: Confusion about JDBC + TIME WITHOUT TIME ZONE |
Date: | 2016-01-25 11:42:03 |
Message-ID: | CAB=Je-FhbUaqzfgiqzjidpK+Qe46rHHu6drFwgT=6JK8rF3K0w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Raiskup | 2016-01-25 11:44:17 | Re: Merge pgjdbc-parent-poms project into pgjdbc please |
Previous Message | Pavel Raiskup | 2016-01-25 11:39:52 | Re: Merge pgjdbc-parent-poms project into pgjdbc please |