From: | Dave Cramer <pg(at)fastcrypt(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 00:32:33 |
Message-ID: | CADK3HHLovZvXnks7FKWh4jRf4LHtLDYEijRzMzzFvDys5=krfg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Well .... timezones in JDBC are certainly a thorny issue. First off there
is no JDBC allowance for any date/time object with out time zones. We have
to support time and date with time zones properly. That being said JDBC
spec says that if you do not provide a timezone then the timezone of the
JVM will be used. So the solution to your problem is to provide a 0
timezone.
See
http://stackoverflow.com/questions/18447995/postgresql-9-2-jdbc-driver-uses-client-time-zone
for others discussing this.
Dave Cramer
davec(at)postgresintl(dot)com
www.postgresintl.com
On 24 January 2016 at 19:00, Bill Moran <wmoran(at)potentialtech(dot)com> wrote:
>
> I have a table that has a TIME WITHOUT TIME ZONE column.
>
> When I try to insert via JDBC, the time is always adjusted for the
> JVM's time zone. This behavior seems wrong to me. For example:
>
> // Java code:
> preparedStatement.setTime(1, Time.valueOf("00:00:10"));
>
> Then, watching the PostgreSQL logs, I see that the value supplied
> for parameter #1 is '05:00:10'.
>
> Since my TZ is US Eastern, it appears as if JDBC is adjusting for
> the timezone. I don't understand why it would do so, as the whole
> point is that TIME WITHOUT TIME ZONE doesn't care, record, or
> do anything else with or about the TZ.
>
> To me, this feels like a bug. I'm certainly open to someone explaining
> to me why this is the correct behavior, so I can stop understanding
> it wrong (should that be the case) but that would have to include an
> understanding of how to get the desired behavior. That behavior is
> that the time passed in is stored without caring about its time zone.
>
> --
> Bill Moran
>
>
> --
> Sent via pgsql-jdbc mailing list (pgsql-jdbc(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-jdbc
>
From | Date | Subject | |
---|---|---|---|
Next Message | Bill Moran | 2016-01-25 01:51:22 | Re: Confusion about JDBC + TIME WITHOUT TIME ZONE |
Previous Message | Bill Moran | 2016-01-25 00:00:35 | Confusion about JDBC + TIME WITHOUT TIME ZONE |