Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 4A0899FA5F0 for ; Thu, 9 Nov 2006 16:16:36 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 73970-06 for ; Thu, 9 Nov 2006 16:16:30 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from web60221.mail.yahoo.com (web60221.mail.yahoo.com [209.73.178.109]) by postgresql.org (Postfix) with SMTP id 5057C9FA5CE for ; Thu, 9 Nov 2006 16:16:30 -0400 (AST) Received: (qmail 17693 invoked by uid 60001); 9 Nov 2006 20:16:29 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type; b=iwvPqdJt+iG3KapriHdBErLRIYDNsnZnkE9a7fIQqfxRqPNLyXQy0HG4uEkW6rV6jl+hALufJYD4L1cRjd69hoKrlIgScSB210ci6wVE1zflWCLtFA6x5W1XJ0I6ZKud1uinegPGLeGnkAKDmHlpIFESIFSU0jU+1kxaZ1LvOl0= ; Message-ID: <20061109201629.17691.qmail@web60221.mail.yahoo.com> Received: from [65.223.207.194] by web60221.mail.yahoo.com via HTTP; Thu, 09 Nov 2006 12:16:29 PST Date: Thu, 9 Nov 2006 12:16:29 -0800 (PST) From: Richard Cook Subject: Bug in TimestampUtils.java? To: pgsql-jdbc@postgresql.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-549742790-1163103389=:15639" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=3.112 tagged_above=0 required=5 tests=BAYES_20, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, DNS_FROM_RFC_WHOIS, HTML_40_50, HTML_MESSAGE X-Spam-Level: *** X-Archive-Number: 200611/41 X-Sequence-Number: 16083 --0-549742790-1163103389=:15639 Content-Type: text/plain; charset=ascii Content-Transfer-Encoding: quoted-printable Hi All,=0A=0AI recently ran into a problem that was partially caused=0Aby s= ome behaviour I found in TimestampUtils.java. To me it does not=0Aseem rig= ht...=0A=0AI retrieved a Timestamp Column from Postgres as a=0ADate. The da= ta in the database had a timezone of GMT -0500, the current=0Atime was also= in GMT -0500. If you look at the date that is returned=0Afrom resultSet.ge= tDate() on a Timestamp column, the timezone for the=0ADate object is -0400.= I would think that it should be -0500.=0A=0AHere=0Ais some sample code tha= t illustrates the bug. Because TimestampUtils=0Adoes not have a public cons= truct I made my own public class from the=0Asource, to use in this example.= ..=0A=0AThanks,=0ARich=0A=0A=0ATODAY: 2006-11-09 15:06:31 -0500=0ADate Stri= ng: 2006-10-29 23:00:00-05=0AParsed date '2006-10-29 23:00:00-05' in zone= =0A America/New_York as 2006-10-29 AD 00:00:00 -0400 (millis=3D116209440000= 0)=0AConverted Date: 2006-10-29 00:00:00 -0400=0A=0A=0ATimestampUtils utils= =3D new TimestampUtils(true);=0A =0A SimpleDateFormat format= ter =3D new SimpleDateFormat(=0A "yyyy-MM-dd HH:mm:ss Z");=0A = =0A Date theTime;=0A try {=0A =0A Syste= m.out.println("TODAY: " + formatter.format(new Date()));=0A Stri= ng dateString =3D "2006-10-29 23:00:00-05";=0A System.out.printl= n("Date String: " + dateString);=0A theTime =3D=0A utils.toDate(= null,dateString);=0A System.out.println("Converted Date: " + for= matter.format(theTime));=0A =0A } catch (SQLException e1)= {=0A // TODO Auto-generated catch block=0A e1.printS= tackTrace();=0A }=0A --0-549742790-1163103389=:15639 Content-Type: text/html; charset=ascii Content-Transfer-Encoding: quoted-printable
Hi All,

I recently ran into a problem that was partially c= aused=0Aby some behaviour I found in TimestampUtils.java.  To me it do= es not=0Aseem right...

I retrieved a Timestamp Column from Postgres = as a=0ADate. The data in the database had a timezone of GMT -0500, the curr= ent=0Atime was also in GMT -0500. If you look at the date that is returned= =0Afrom resultSet.getDate() on a Timestamp column, the timezone for the=0AD= ate object is -0400. I would think that it should be -0500.

Here=0Ai= s some sample code that illustrates the bug. Because TimestampUtils=0Adoes = not have a public construct I made my own public class from the=0Asource, t= o use in this example...

Thanks,
Rich


TODAY: 2006-11-0= 9 15:06:31 -0500
Date String: 2006-10-29 23:00:00-05
Parsed date '200= 6-10-29 23:00:00-05' in zone=0A America/New_York as 2006-10-29 AD 00:00:00 = -0400 (millis=3D1162094400000)
Converted Date: 2006-10-29 00:00:00 -0400=


TimestampUtils utils =3D new TimestampUtils(true);
 &nb= sp;     
        Simp= leDateFormat formatter =3D new SimpleDateFormat(
    &nbs= p;   "yyyy-MM-dd HH:mm:ss Z");
      =
        Date theTime;
  &nb= sp;     try {
         = ;  
            = System.out.println("TODAY: " + formatter.format(new Date()));
 &nbs= p;          String dateString =3D "2006-= 10-29 23:00:00-05";
          &n= bsp; System.out.println("Date String: " + dateString);
   = ;         theTime =3D=0A utils.toDate(null,da= teString);
            Syst= em.out.println("Converted Date: " + formatter.format(theTime));
 &n= bsp;         
    &nb= sp;   } catch (SQLException e1) {
     &nb= sp;      // TODO Auto-generated catch block
 &n= bsp;          e1.printStackTrace();
&= nbsp;       }
--0-549742790-1163103389=:15639--