pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Vinayak <vinpokale@gmail.com>
To: pgsql-jdbc@postgresql.org
Subject: Re: Problem with DATE
Date: Mon, 19 Jan 2015 05:48:52 -0700 (MST)
Message-ID: <1421671732288-5834546.post@n5.nabble.com> (raw)
In-Reply-To: <54B9433B.6070706@ttc-cmc.net>
References: <CADK3HHK0hvZ1sWgze7AsxwcGF+8aNWZHvCitkQ-aKHmmYyzPTA@mail.gmail.com>
	<1421061400959-5833623.post@n5.nabble.com>
	<CADK3HHK5cWLDZCigT_WTg=KZB+r84_8CprjzZzH7WMvZ7FRCjw@mail.gmail.com>
	<1421123270940-5833702.post@n5.nabble.com>
	<1421131374401-5833708.post@n5.nabble.com>
	<CADK3HHKogHhRauJ9w9Dr=H_qinbaZcc6v6ZLXYnAuaxLmLz0xg@mail.gmail.com>
	<1421213697306-5833860.post@n5.nabble.com>
	<CADK3HHLLUh3AiTqhVgWRfwoqXaj3hicMAg-SuD4X0qoMoRvbAw@mail.gmail.com>
	<1421386506791-5834215.post@n5.nabble.com>
	<54B9433B.6070706@ttc-cmc.net>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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.


-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



view thread (20+ messages)  latest in thread

Message-ID: <1421671732288-5834546.post@n5.nabble.com>
Permalink:  ../1421671732288-5834546.post@n5.nabble.com/
Also on:    postgresql.org/message-id/1421671732288-5834546.post@n5.nabble.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: vinpokale@gmail.com
  Subject: Re: Problem with DATE
  In-Reply-To: <1421671732288-5834546.post@n5.nabble.com>
  References: <CADK3HHK0hvZ1sWgze7AsxwcGF+8aNWZHvCitkQ-aKHmmYyzPTA@mail.gmail.com> <1421061400959-5833623.post@n5.nabble.com> <CADK3HHK5cWLDZCigT_WTg=KZB+r84_8CprjzZzH7WMvZ7FRCjw@mail.gmail.com> <1421123270940-5833702.post@n5.nabble.com> <1421131374401-5833708.post@n5.nabble.com> <CADK3HHKogHhRauJ9w9Dr=H_qinbaZcc6v6ZLXYnAuaxLmLz0xg@mail.gmail.com> <1421213697306-5833860.post@n5.nabble.com> <CADK3HHLLUh3AiTqhVgWRfwoqXaj3hicMAg-SuD4X0qoMoRvbAw@mail.gmail.com> <1421386506791-5834215.post@n5.nabble.com> <54B9433B.6070706@ttc-cmc.net> <1421671732288-5834546.post@n5.nabble.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox