Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id B630B6506C6 for ; Tue, 8 Jul 2008 05:08:28 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 51378-06-4 for ; Tue, 8 Jul 2008 05:07:49 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from tremor.opencloud.co.nz (tremor.opencloud.co.nz [131.203.101.230]) by postgresql.org (Postfix) with ESMTP id 8F353650EBE for ; Tue, 8 Jul 2008 05:06:55 -0300 (ADT) Received: from 222-154-180-72.jetstream.xtra.co.nz ([222.154.180.72] helo=[192.168.1.3]) by tremor.opencloud.co.nz with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1KG8Dp-0005lV-Hi; Tue, 08 Jul 2008 20:06:49 +1200 Message-ID: <4873201F.1000700@opencloud.com> Date: Tue, 08 Jul 2008 20:06:55 +1200 From: Oliver Jowett User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 To: Ken Johanson CC: pgsql-jdbc@postgresql.org Subject: Re: Timestamp without Timezone and differing client / server tzs References: <4873154E.6020808@kensystem.com> In-Reply-To: <4873154E.6020808@kensystem.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200807/11 X-Sequence-Number: 18796 Ken Johanson wrote: > Question: with ts without tz storage, should not a timestamp be > normalized to the servers implicit TZ (UTC in this case), since that is > set in the config's client-tz? If you don't specify a Calendar to setTimestamp, it's assumed you mean the client JVM's default timezone (the same timezone that Timestamp.toString() assumes). So if you have a Timestamp for 07:09 UTC, and your client JVM's default timezone is +0700, then setTimestamp() will send "... 14:09 +0700". That'll be stored as 14:09 in a timestamp-without-timezone field. (Note that setTimestamp() doesn't know if it's setting a with or without timezone parameter, so it always puts a timezone in the value and lets the server ignore it where appropriate) Similarly, if you select a ts-without-timezone value, it's turned into a Timestamp representing that time in the client JVM's default timezone. This behaviour is set up so that you get the intuitively correct results such that e.g. Timestamp.getHours() matches the raw hours value of a ts-without-timezone in the DB when you set or get it. It doesn't really make any sense to use the server's timezone here, because all the interpretation/formatting is happening on the client side, and the standard Java libs know nothing about the server's timezone. If you want to interpret a Timestamp as being in a particular timezone, use the getTimestamp()/setTimestamp() variants that take an explicit Calendar. -O