Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U2Dej-00079Q-3E for pgsql-jdbc@arkaria.postgresql.org; Mon, 04 Feb 2013 04:27:45 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U2Dei-00005e-2U for pgsql-jdbc@arkaria.postgresql.org; Mon, 04 Feb 2013 04:27:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U2Deh-00005Y-9J for pgsql-jdbc@postgresql.org; Mon, 04 Feb 2013 04:27:43 +0000 Received: from plane.gmane.org ([80.91.229.3]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U2Dee-0007vR-M9 for pgsql-jdbc@postgresql.org; Mon, 04 Feb 2013 04:27:42 +0000 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1U2Det-0006sj-La for pgsql-jdbc@postgresql.org; Mon, 04 Feb 2013 05:27:55 +0100 Received: from pool-71-170-109-80.dllstx.fios.verizon.net ([71.170.109.80]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 04 Feb 2013 05:27:55 +0100 Received: from arequipeno by pool-71-170-109-80.dllstx.fios.verizon.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 04 Feb 2013 05:27:55 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-jdbc@postgresql.org From: Ian Pilcher Subject: setTimestamp(int, Timestamp, Calendar) ignoring time zone? Date: Sun, 03 Feb 2013 23:27:25 -0500 Lines: 44 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: pool-71-170-109-80.dllstx.fios.verizon.net User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 X-Pg-Spam-Score: -1.0 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org 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