Return-Path: Delivered-To: apmail-db-torque-user-archive@www.apache.org Received: (qmail 5379 invoked from network); 7 Apr 2004 00:58:27 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 7 Apr 2004 00:58:27 -0000 Received: (qmail 8217 invoked by uid 500); 7 Apr 2004 00:58:08 -0000 Delivered-To: apmail-db-torque-user-archive@db.apache.org Received: (qmail 8199 invoked by uid 500); 7 Apr 2004 00:58:08 -0000 Mailing-List: contact torque-user-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Apache Torque Users List" Reply-To: "Apache Torque Users List" Delivered-To: mailing list torque-user@db.apache.org Received: (qmail 8184 invoked from network); 7 Apr 2004 00:58:08 -0000 Received: from unknown (HELO NTSERV01.InformativeResearch.com) (65.163.59.170) by daedalus.apache.org with SMTP; 7 Apr 2004 00:58:08 -0000 Received: by ntserv01.informativeresearch.com with Internet Mail Service (5.5.2657.72) id <22WX3ZZ1>; Tue, 6 Apr 2004 17:57:28 -0700 Message-ID: <961883FD16B5854AA73F31449A3EC8F302248CD1@ntserv01.informativeresearch.com> From: Benjamin Yu To: 'Apache Torque Users List' Subject: RE: Time Zone with Torque and PostgreSQL Date: Tue, 6 Apr 2004 17:57:25 -0700 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2657.72) Content-Type: text/plain X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N I'm not sure if option 2 will work for you...because new Date() and new Date(new GregorianCalendar().getTimeInMillis()) will create a new object of the same time. Java API states that Date "is intended to reflect coordinated universal time (UTC)". To which the Default constructor "initializes it so that it represents the time at which it was allocated". And "the DateFormat class should be used to format and parse date strings" The java.text.DateFormat uses the values from TimeZone.getDefault() and the value set by dateFormat.setTimeZone() to correctly output a string with the proper timezone adjustments. I believe that the client's "localtime" will be inserted into the table when inserting a new Date() regardless of whatever timezone the server is in. This effect appears to happen also with ms sql server's datetime. >1) I could use the PostgreSQL datatype "timestamp with time zone" though > I'm wondering if/how Torque will handle this datatype? The default postgresql templates just use the "timestamp" datatype. Thus, there will be no timezone conversion. However, one could modify the torque-gen-3.1\templates\sql\base\postgresql\db.props file to add "with time zone". There's always option 3) set the jvm's timezone to utc in the environment. However, I'm not sure which one of the options that i discussed to advocate. :) But I am leaning towards option one... to make the timestamp columns in the database timezone aware... -Ben -----Original Message----- From: Sica, David (David) [mailto:dsica@avaya.com] Sent: Tuesday, April 06, 2004 10:28 AM To: torque-user@db.apache.org Subject: Time Zone with Torque and PostgreSQL I have an application that could be running on servers in different time zones. I'm storing several columns of data in PostgreSQL using the timestamp datatype. I now realize that I need to record the time zone as part of the timestamp as this application could be inserting into the database from different time zones. I'm trying to determine the best way to handle this situation. Here's some thoughts: 1) I could use the PostgreSQL datatype "timestamp with time zone" though I'm wondering if/how Torque will handle this datatype? 2) I could always store the timestamp in UTC by calling new Calendar().getTimeInMillis() and setting this value in my Torque data object. Are there any comments or suggestions for implementation? Thanks, David Sica --------------------------------------------------------------------- To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org For additional commands, e-mail: torque-user-help@db.apache.org