Re: Problem with DATE

Поиск
Список
Период
Сортировка
От Vinayak
Тема Re: Problem with DATE
Дата
Msg-id 1421671732288-5834546.post@n5.nabble.com
обсуждение исходный текст
Ответ на Re: Problem with DATE  (dmp <danap@ttc-cmc.net>)
Ответы Re: Problem with DATE  (dmp <danap@ttc-cmc.net>)
Список 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.


В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Scott Morgan
Дата:
Сообщение: Docs java 1.7 and 1.8
Следующее
От: Vinayak
Дата:
Сообщение: Re: Problem with DATE