pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Jowett <oliver@opencloud.com>
To: Dave Cramer <pg@fastcrypt.com>
Cc: Kevin Grittner <Kevin.Grittner@wicourts.gov>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Timestamp Conversion Woes Redux
Date: Sat, 23 Jul 2005 19:21:13 +1200
Message-ID: <42E1EFE9.8040804@opencloud.com> (raw)
In-Reply-To: <2B25D0C2-4C32-4641-91B7-48DAA498B9C9@fastcrypt.com>
References: <s2dfc8ca.027@gwmta.wicourts.gov>
	<2B25D0C2-4C32-4641-91B7-48DAA498B9C9@fastcrypt.com>

Dave Cramer wrote:
> I looked for this in the trail, and couldn't find it.
> So here it is verbatim
> 
> setTimestamp with a calendar
> 
> Sets parameter number parameterIndex to x. When the DBMS does not  store
> time zone information, the driver will use cal to construct a  JDBC
> Timestamp value which it then sends to the database. With a  Calendar
> object the driver can calculate the Timestamp object taking  into
> account a custom time zone. If no Calendar object is specified,  the
> driver uses the time zone of the Virtual Machine that is running  the
> application.
> 
> 
> So my interpretation is.
> 
> If we are storing a timestamptz then ignore cal and use the server  time
> zone
> If we are storing a timestamp then use cal to calculate the  timestamp;
> if cal is null then use the JVM's  time zone.

Couple of things..

a) How do we know what type we are storing without invoking UNKNOWN again?
b) The server doesn't actually store timezone information with a
timestamptz (this confused me initially, but Tom clarified), so
shouldn't we be doing what the book says and *using* the calendar when
we store to a timestamptz? (it's just a representation issue, it doesn't
actually affect the value stored in the end.. unless you plug it into a
text column or something..)

> That aside:
> 
> If the server provides time zone info, use that to create the 
> timestamp, regardless of calendar supplied
> if the server does not provide time zone info, use calendar supplied, 
> if that is null or not supplied then use JVM calendar.

That makes sense -- basically it means that if we are reading a
timestamptz we construct the Timestamp directly to represent that
instant, ignoring the calendar supplied. If we are reading a timestamp,
then we turn it into a Timestamp using the provided or JVM-default calendar.

-O



view thread (92+ messages)

Message-ID: <42E1EFE9.8040804@opencloud.com>
Permalink:  ../42E1EFE9.8040804@opencloud.com/
Also on:    postgresql.org/message-id/42E1EFE9.8040804@opencloud.com

 · 

reply

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@fastcrypt.com, Kevin.Grittner@wicourts.gov
  Subject: Re: Timestamp Conversion Woes Redux
  In-Reply-To: <42E1EFE9.8040804@opencloud.com>
  References: <s2dfc8ca.027@gwmta.wicourts.gov> <2B25D0C2-4C32-4641-91B7-48DAA498B9C9@fastcrypt.com> <42E1EFE9.8040804@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