Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id E24331337B8F for ; Wed, 1 Dec 2010 19:42:06 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 08956-01-2 for ; Wed, 1 Dec 2010 23:42:00 +0000 (UTC) X-Greylist: delayed 00:16:11.681773 by SQLgrey-1.7.6 Received: from tremor.opencloud.co.nz (tremor.opencloud.co.nz [131.203.101.230]) by mail.postgresql.org (Postfix) with ESMTP id 803331337B91 for ; Wed, 1 Dec 2010 19:41:59 -0400 (AST) Received: from 121-98-80-66.bitstream.orcon.net.nz ([121.98.80.66] helo=[192.168.1.2]) by tremor.opencloud.co.nz with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1PNw3R-0001Bk-97; Thu, 02 Dec 2010 12:25:41 +1300 Message-ID: <4CF6D96F.2060500@opencloud.com> Date: Thu, 02 Dec 2010 12:25:35 +1300 From: Oliver Jowett User-Agent: Thunderbird 2.0.0.24 (X11/20101027) MIME-Version: 1.0 To: =?UTF-8?B?UmFkb3PFgmF3IFNtb2d1cmE=?= CC: pgsql-jdbc@postgresql.org Subject: Re: Storing timestamps in text format References: In-Reply-To: X-Enigmail-Version: 0.95.7 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201012/14 X-Sequence-Number: 21252 Radosław Smogura wrote: > Hi, > > I perform following test: > 1. Open connection (GMT+1) > 2. Change timezone (GMT+3) > 3. Write created timestamp. > 4. Change timezone to different connection open and write (GMT+4) > 5. Read timezone > > During this I saw driver sends timestamp encoded with initial (in my case > +1), form connection open, time zone. It's because > TimestampUtils.toString(Calendar, Timestamp) uses defaultCal. Should it use > Calendar.getInstance() or new GregorianCalendar? > > public synchronized String toString(Calendar cal, Timestamp x) { > if (cal == null) > cal = defaultCal; // = Calendar.getInstance() // new > GregorianCalendar() There seems to be some confusion about what the bug you are reporting actually is. Is the bug that if you change the JVM's default timezone halfway through a run, the change is not reflected in the driver? (i.e. defaultCal is initialized once only). Or is it something else? I vaguely remember that when writing this code, getting the default calendar was quite expensive.. Oliver