From: Oliver Jowett <oliver@opencloud.com>
To: Ken Johanson <pg-user@kensystem.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Timestamp without Timezone and differing client / server tzs
Date: Tue, 08 Jul 2008 20:06:55 +1200
Message-ID: <4873201F.1000700@opencloud.com> (raw)
In-Reply-To: <4873154E.6020808@kensystem.com>
References: <4873154E.6020808@kensystem.com>
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
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: oliver@opencloud.com, pg-user@kensystem.com
Subject: Re: Timestamp without Timezone and differing client / server tzs
In-Reply-To: <4873201F.1000700@opencloud.com>
References: <4873154E.6020808@kensystem.com> <4873201F.1000700@opencloud.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