From: | Vinayak <vinpokale(at)gmail(dot)com> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: Problem with DATE |
Date: | 2015-01-19 12:48:52 |
Message-ID: | 1421671732288-5834546.post@n5.nabble.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Hi,
I tried to use setDate() instead of setObject() but still it gives the same
error.
Example:
ps = conn.prepareStatement("SELECT ?");
java.sql.Date sqlDate1 = new java.sql.Date(new java.util.Date().getTime());
ps.setDate(6, sqlDate1);
The problem here is java DATE have timezone and time.
The comment in the PostgreSQL jdbc driver code:
// We must use UNSPECIFIED here, or inserting a Date-with-timezone
into a
// timestamptz field does an unexpected rotation by the server's
TimeZone:
//
// We want to interpret 2005/01/01 with calendar +0100 as
// "local midnight in +0100", but if we go via date it interprets it
// as local midnight in the server's timezone:
// template1=# select '2005-01-01+0100'::timestamptz;
// timestamptz
// ------------------------
// 2005-01-01 02:00:00+03
// (1 row)
// template1=# select '2005-01-01+0100'::date::timestamptz;
// timestamptz
// ------------------------
// 2005-01-01 00:00:00+03
// (1 row)
-----
Regards,
Vinayak,
--
View this message in context: http://postgresql.nabble.com/Problem-with-DATE-tp5833008p5834546.html
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.
From | Date | Subject | |
---|---|---|---|
Next Message | Vinayak | 2015-01-19 13:00:13 | Re: Problem with DATE |
Previous Message | Scott Morgan | 2015-01-19 10:14:03 | Docs java 1.7 and 1.8 |