X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C9D6A528C6 for ; Tue, 19 Jul 2005 08:26:11 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 00607-02 for ; Tue, 19 Jul 2005 11:26:00 +0000 (GMT) Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.195]) by svr1.postgresql.org (Postfix) with ESMTP id D0C8E528BD for ; Tue, 19 Jul 2005 08:25:58 -0300 (ADT) Received: by zproxy.gmail.com with SMTP id s1so1130471nze for ; Tue, 19 Jul 2005 04:26:02 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Qg7Nz0MvPq5CHjLiK2HLyFJC93i0sBIUsoTwwZXwdR4fCHJAVtfM5lgDa0kFCCqxSws8zoX4JK3Gsv4QZ4EIE46Ht5aGDq28uTgcrFTXX/Jx1Ifo7CTw+XdSufoYSrcNpIN2L0cfWu+F6InV4LefP6VPYgFpYs+sVCpYVGXvMDg= Received: by 10.36.36.15 with SMTP id j15mr4203547nzj; Tue, 19 Jul 2005 04:25:36 -0700 (PDT) Received: by 10.36.221.58 with HTTP; Tue, 19 Jul 2005 04:25:36 -0700 (PDT) Message-ID: Date: Tue, 19 Jul 2005 13:25:36 +0200 From: im i Reply-To: im i To: Dave Cramer Subject: Re: newbie question to setTimestamp( int parameterIndex, Timestamp x, Calendar cal) Cc: Peter.Zoche@materna.de, pgsql-jdbc@postgresql.org In-Reply-To: <1C7D4610-DD9B-4D42-BE3C-B2257D099D2D@fastcrypt.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <3617A3C21370D045B75C0A40A7A6530D0B37E17E@ntexc2buc.do-office.buc.materna.com> <1C7D4610-DD9B-4D42-BE3C-B2257D099D2D@fastcrypt.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.024 tagged_above=0 required=5 tests=RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200507/122 X-Sequence-Number: 13270 Hi, This is 2 static method what convert from/to TimeStamp/GregorianCalendar: public static Timestamp Gregorian2Timestamp(GregorianCalendar gregorianCalendar) { return (gregorianCalendar =3D=3D null ? null : new java.sql.Timestamp(gregorianCalendar.getTimeInMillis())); } public static GregorianCalendar Timestamp2Gregorian(Timestamp timestamp) { GregorianCalendar result =3D null; if (timestamp !=3D null) { result =3D new GregorianCalendar(); result.setTime(new Date(timestamp.getTime())); } return (result); } linimi On 7/19/05, Dave Cramer wrote: > Peter, >=20 > Timestamp is the actual time that you want to store. The calendar > object is there if you want to use a different calendar to reference > the timestamp to ? >=20 > Dave > On 19-Jul-05, at 6:49 AM, Peter.Zoche@materna.de wrote: >=20 > > Hi all! > > > > I am new to postgresql and i have the following question: > > > > how does setTimestamp( int parameterIndex, Timestamp x, Calendar > > cal) work? > > why is there a parameter Timestamp? I have a Calendar in my java > > code and I > > would like to store it in the database via a PreparedStatement. So for > > example: > > > > I have the following table: > > > > CREATE TABLE dates( date TIMESTAMP WITH TIME ZONE ); > > > > Java code: > > > > PreparedStatement ps =3D connection.prepareStatement( "INSERT INTO > > dates (date) VALUES ?"); > > ps.setTimestamp( 1, new Timestamp(), myCalendar ); > > > > Is this correct? But why is there a Timestamp parameter? It seems > > clear that > > the > > calendar should be converted into a timestamp because the method is > > named > > setTimestamp. I am really confused about this. > > > > Please help > > > > Peter > > > > ---------------------------(end of > > broadcast)--------------------------- > > TIP 4: Have you searched our list archives? > > > > http://archives.postgresql.org > > > > >=20 >=20 > ---------------------------(end of broadcast)--------------------------- > TIP 2: Don't 'kill -9' the postmaster >