From: Ian Pilcher <arequipeno@gmail.com>
To: pgsql-jdbc@postgresql.org
Subject: setTimestamp(int, Timestamp, Calendar) ignoring time zone?
Date: Sun, 03 Feb 2013 23:27:25 -0500
Message-ID: <kendbb$843$1@ger.gmane.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>
I am trying to use a Calendar parameter to setTimestamp. From what I've
read, using a Calendar with a non-default time zone should change the
value that is written to my table:
> public static void main(String[] args) throws Exception
> {
> System.out.println(
> "System time zone is " + TimeZone.getDefault().getID());
> Calendar c = Calendar.getInstance(
> TimeZone.getTimeZone("America/Chicago"));
> Class.forName(JDBC_DRIVER_CLASS);
> Connection db =
> DriverManager.getConnection(DB_URL, DB_USER, DB_PASSWD);
> Statement s = db.createStatement();
> s.execute("DELETE FROM foo");
> PreparedStatement ps =
> db.prepareStatement("INSERT INTO foo (bar) VALUES (?)");
> ps.setTimestamp(1, Timestamp.valueOf("2013-02-01 00:00:00"));
> ps.execute();
> ps.setTimestamp(1, Timestamp.valueOf("2013-02-01 00:00:00"), c);
> ps.execute();
> ResultSet rs = s.executeQuery("SELECT * FROM foo");
> while (rs.next()) {
> System.out.println(rs.getTimestamp(1));
> }
> db.close();
> }
The output from the program is:
> System time zone is America/New_York
> 2013-02-01 00:00:00.0
> 2013-02-01 00:00:00.0
Is this a bug/missing feature in the driver, or am I doing something
wrong?
Thanks!
--
========================================================================
Ian Pilcher arequipeno@gmail.com
Sometimes there's nothing left to do but crash and burn...or die trying.
========================================================================
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc
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: arequipeno@gmail.com
Subject: Re: setTimestamp(int, Timestamp, Calendar) ignoring time zone?
In-Reply-To: <kendbb$843$1@ger.gmane.org>
References: <kendbb$843$1@ger.gmane.org>
* 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