Return-Path: Delivered-To: apmail-incubator-cayenne-user-archive@locus.apache.org Received: (qmail 84162 invoked from network); 5 Dec 2006 17:19:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Dec 2006 17:19:39 -0000 Received: (qmail 76465 invoked by uid 500); 5 Dec 2006 17:19:47 -0000 Delivered-To: apmail-incubator-cayenne-user-archive@incubator.apache.org Received: (qmail 76449 invoked by uid 500); 5 Dec 2006 17:19:47 -0000 Mailing-List: contact cayenne-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cayenne-user@incubator.apache.org Delivered-To: mailing list cayenne-user@incubator.apache.org Received: (qmail 76440 invoked by uid 99); 5 Dec 2006 17:19:47 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Dec 2006 09:19:47 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [217.72.192.184] (HELO fmmailgate09.web.de) (217.72.192.184) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Dec 2006 09:19:35 -0800 Received: from web.de by fmmailgate09.web.de (Postfix) with SMTP id C22041FCD07 for ; Tue, 5 Dec 2006 18:19:13 +0100 (CET) Received: from [62.206.40.35] by freemailng9902.web.de with HTTP; Tue, 05 Dec 2006 18:19:12 +0100 Date: Tue, 05 Dec 2006 18:19:12 +0100 Message-Id: <452201454@web.de> MIME-Version: 1.0 From: Lothar Krenzien To: cayenne-user@incubator.apache.org Subject: Re: how does cayenne handle java.util.date values ? Organization: http://freemail.web.de/ Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org > -----Urspr=FCngliche Nachricht----- > Von: cayenne-user@incubator.apache.org > Gesendet: 05.12.06 14:33:50 > An: cayenne-user@incubator.apache.org > Betreff: Re: how does cayenne handle java.util.date values =3F > On Dec 5, 2006, at 14:26 , Lothar Krenzien wrote: >=20 > > I've provided a simple demo class to show what I mean. I used Java =20 > > 5, cayenne 2.1 and jtds with MS SQL Server 2000. >=20 > Looks like the attachment are striped by the mail-list software. =20 > Could you copy/paste the code into the mail instead of attaching the =20 > java file=3F >=20 > - Tore. >=20 Ok here's the sample : ------------------------------------------------------------------ import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class CayenneDateTest { public static void main(String[] args) { try { System.out.println("litte java date parsing + formating sample"); doTest(); } catch (Exception e) { e.printStackTrace(); } } private static void doTest() throws Exception { // the string value from the xml file String dateValue =3D "28.10.2006 22:14:28"; TimeZone timeZone =3D TimeZone.getTimeZone("Asia/Seoul"); SimpleDateFormat dateFormat =3D new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"= ); dateFormat.setTimeZone(timeZone); Date parsedDate =3D dateFormat.parse(dateValue); System.out.println("parsedDate:" + parsedDate); // this will be stored b= y cayenne dateFormat =3D new SimpleDateFormat("dd.MM.yyyy HH:mm:ss zzzz"); dateFormat.setTimeZone(timeZone); String formattedDate =3D dateFormat.format(parsedDate); System.out.println("formattedDate:" + formattedDate); dateFormat =3D new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); dateFormat.setTimeZone(timeZone); formattedDate =3D dateFormat.format(parsedDate); System.out.println("formattedDate:" + formattedDate); // this is what I = like to be stored by cayenne } private static void doImport() { // this is a pseudo example how the real application does the db import /* String dataDate =3D "28.10.2006 22:14:28" ; TimeZone timeZone =3D TimeZone.getTimeZone("Asia/Seoul"); SimpleDateFormat dateFormat =3D new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"= ); dateFormat.setTimeZone(timeZone); Date parsedDate =3D dateFormat.parse(dataDate); TblImportEffBlockData importData =3D (TblImportEffBlockData)context.create= AndRegisterNewObject(TblImportEffBlockData.class); importData.setDataDate(parsedDate); context.commitChanges();*/ /* -- cayenne log output INSERT INTO dbo.tblImportEffBlockData (dataDate) bind: '2006-10-28 15:14:28.0' */ /* -- db table definition CREATE TABLE [dbo].[tblImportEffBlockData] ( [importEffBlockDataId] [int] IDENTITY (1, 1) NOT NULL , [dataDate] [datetime] NOT NULL ) ON [PRIMARY] GO */ } } ------------------------------------------------------------------ =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= =5F=5F=5F=5F "Ein Herz f=FCr Kinder" - Ihre Spende hilft! Aktion: www.deutschlandsegelt.d= e Unser Dankesch=F6n: Ihr Name auf dem Segel der 1. deutschen America's Cup-Ya= cht!