Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 51396 invoked from network); 26 Feb 2008 14:42:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 26 Feb 2008 14:42:20 -0000 Received: (qmail 60080 invoked by uid 500); 26 Feb 2008 14:42:15 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 59914 invoked by uid 500); 26 Feb 2008 14:42:15 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 59900 invoked by uid 99); 26 Feb 2008 14:42:15 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Feb 2008 06:42:15 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [17.148.16.67] (HELO smtpoutm.mac.com) (17.148.16.67) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Feb 2008 14:41:40 +0000 Received: from mac.com (asmtp004-s [10.150.69.67]) by smtpoutm.mac.com (Xserve/smtpout004/MantshX 4.0) with ESMTP id m1QEfmb1010334 for ; Tue, 26 Feb 2008 06:41:48 -0800 (PST) Received: from [192.168.1.44] (222-112.5-85.cust.bluewin.ch [85.5.112.222]) (authenticated bits=0) by mac.com (Xserve/asmtp004/MantshX 4.0) with ESMTP id m1QEfF9m028381 for ; Tue, 26 Feb 2008 06:41:46 -0800 (PST) Message-Id: From: "Alexander Lamb (dev)" To: user@cayenne.apache.org In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Apple Message framework v919.2) Subject: Re: Storing GMT dates? Date: Tue, 26 Feb 2008 15:41:14 +0100 References: <26EA19B5-7BF6-4E01-AEE5-7E6324BD2A88@rodanotech.ch> <180A0CD4-60B7-490F-B19B-D8432DCC4C87@mac.com> X-Mailer: Apple Mail (2.919.2) X-Virus-Checked: Checked by ClamAV on apache.org But that's what I am doing. I did create a Calendar object initialized as a GMT "now". Then I =20 simply do a "getTime()" on it. Now, when I print the result of the getTime() I get the local time, =20 but that's because of the locale. That's why I am suspecting Cayenne =20 to printout the Date object and the local being what it is, I end up =20 storing a local time. I know the database has no knowledge of time =20 zones, and that's why I want to store GMT times (and therefore also =20 avoid the daylight saving times passage problems). So it summarizes to "how do I tell cayenne to use GMT when generating =20= the SQL to insert my Date" (and this, only in some areas). ? Alex Le 26 f=E9vr. 08 =E0 15:01, Michael Gentry a =E9crit : > Sorry Alexander, I meant to reply to this. > > Most databases, to my knowledge, do not store dates with a time zone > associated with them. I haven't played too much with storing things > in GMT or any other specific time zone, but I would imagine that > you'll need a helper method to do the time zone translations for you. > For example, override the get/set methods in your subclass to convert > from/to GMT. (This means you'll have to physically convert the time, > not just apply the time zone offset.) > > Maybe someone else will correct me if I'm wrong on this, but that is > the first approach I would try. > > /dev/mrg > > On Tue, Feb 26, 2008 at 8:25 AM, Alexander Lamb (dev) =20 > wrote: >> Maybe I can rephrase the question: does Cayenne do any kind of >> transformation when storing Date objects in TIMESTAMP fields? >> >> If so, how can I control this? >> >> Thanks, >> >> Alex >> >> Le 25 f=E9vr. 08 =E0 16:17, Alexander Lamb a =E9crit : >> >> >> >>> Hello, >>> >>> Using Cayenne 3.0M3, MySQL 5. >>> >>> I have a field which is a TIMESTAMP. It maps to a Java.util.Date >>> class in Java. >>> >>> If I do a myObject.setMyTimestamp(new Date()) I will store the local >>> date. >>> >>> I would like to store a GMT date. >>> >>> I tried doing this: >>> >>> Calendar cal =3D Calendar.getInstance(TimeZone.getTimeZone("GMT")); >>> >>> myObject.setMyTimestamp(cal.getTime()); >>> >>> but again, I am back to the local time. Indeed, a trace shows "cal" >>> is correctly set at the GMT value, but cal.getTime() is back to the >>> local time (or at least the printout is, but it is as if Cayenne >>> took the formated value and not the actual date value). >>> >>> How can I solve this problem? >>> >>> Thanks, >>> >>> Alex >>> -- >>> Alexander Lamb >>> Founding Associate >>> RODANOTECH S=E0rl >>> >>> 4 ch. de la Tour de Champel >>> 1206 Geneva >>> Switzerland >>> >>> Tel: 022 347 77 37 >>> Fax: 022 347 77 38 >>> >>> http://www.rodanotech.ch >>> >>> >>> >> >>