Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id DC87E133655C for ; Fri, 7 Jan 2011 11:31:36 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 19950-09 for ; Fri, 7 Jan 2011 15:31:28 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from nm18-vm1.bullet.mail.sp2.yahoo.com (nm18-vm1.bullet.mail.sp2.yahoo.com [98.139.91.215]) by mail.postgresql.org (Postfix) with SMTP id 69FF213364DE for ; Fri, 7 Jan 2011 11:31:27 -0400 (AST) Received: from [98.139.91.70] by nm18.bullet.mail.sp2.yahoo.com with NNFMP; 07 Jan 2011 15:31:27 -0000 Received: from [98.139.91.28] by tm10.bullet.mail.sp2.yahoo.com with NNFMP; 07 Jan 2011 15:31:27 -0000 Received: from [127.0.0.1] by omp1028.mail.sp2.yahoo.com with NNFMP; 07 Jan 2011 15:31:27 -0000 X-Yahoo-Newman-Property: ymail-5 X-Yahoo-Newman-Id: 268011.23817.bm@omp1028.mail.sp2.yahoo.com Received: (qmail 45179 invoked by uid 60001); 7 Jan 2011 15:31:27 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1294414286; bh=AUuVixJ+xTIzR6F/bZCzpG4P0L1UBMZz3Ih6oRcO3PY=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:References:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type; b=HXUUFX24KFbEsRi6UgJs9u9oTnLsmnHexIpT0UgVsJd7jJvIG7jYdPNMls4ye1y7TNWBhSJiDtsvDKYvgDKWawcBDAqvB0AAEqD7l75oTm8Ticw88WKhA1jaLYmaBPe+v/o3jRcx46M55AChnIL/7UAsONa0cGi7bN8oFHbTBxM= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:References:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type; b=A2AIlIpoWn+JSurxBpTjX0zdm2SWYgumvwpHxLXAJbAJyTzCbAFjKYav89q7FmsGnNXdQoq/VL+QutdxK8MPz7L0SO8SdrVb+isLbWrev7wrIJsaR/in2JYhX0Sc8AKsm8uvK4SirJRHhe+Y8Yd8xaUeosEr+UvuLBzibRjbRPA=; Message-ID: <948897.28558.qm@web110410.mail.gq1.yahoo.com> X-YMail-OSG: 8TDxzzIVM1lM4_f1M4OopMJdmeDHCE1CWJK4niTpX9EQI_h fix_3aw8H.7cjNgokBGf147ITv5QOWLv2XH893CRlEie6ObtsPRqbaz86dqi vFikUOrknyLODuWyFlhmaSGS4mfEKSvVlKc6KSGCQ6IUijK45QC8FVW5tW4Z 82IrweuwNvnusvKknSEy6cFZH71ngUs32.ccSW0z1u6.JL0g9izVb4Ui5mTw FdEaJ_D43iBDA.BOIXUEHBuk9U8_KRRlxz.rysUOChg0eq9OPvscl5QTY76H paVH6BYYUVYhROjNgvA6UNlbvXuNQbkGK_t61xx4FW4MPcw9H9ZohBoJ7OUa mlTaKNLYaUK.Q5_n_ZwZLweQUNblHxOWj8aVr4pC5FgxvQQqjxjZEg2B1bps J6t1agfSOWEA- Received: from [119.152.79.14] by web110410.mail.gq1.yahoo.com via HTTP; Fri, 07 Jan 2011 07:31:26 PST X-Mailer: YahooMailRC/553 YahooMailWebService/0.8.107.285259 References: <416690.93407.qm@web110406.mail.gq1.yahoo.com> <4D257BC90200002500039054@gw.wicourts.gov> <766302.42702.qm@web110412.mail.gq1.yahoo.com> <4D2583B20200002500039059@gw.wicourts.gov> <4D25D92702000025000390A0@gw.wicourts.gov> Date: Fri, 7 Jan 2011 07:31:26 -0800 (PST) From: Altaf Malik Subject: Re: Strange behaviour of rs.getTimestamp To: Kevin Grittner Cc: Samuel Gendler , pgsql-jdbc@postgresql.org In-Reply-To: <4D25D92702000025000390A0@gw.wicourts.gov> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1620441473-1294414286=:28558" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.907 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RFC_ABUSE_POST=0.001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201101/18 X-Sequence-Number: 21350 --0-1620441473-1294414286=:28558 Content-Type: text/plain; charset=us-ascii Here is the output of the program run. I also included user.timezone Sun Microsystems Inc. 1.6.0_21 Java HotSpot(TM) 64-Bit Server VM mixed mode TimeZone:Asia/Karachi 2009-04-15 00:00:00->2009-04-15 01:00:00.0 I am using UBUNTU 10.10 64 bit. I don't see this behaviour with other timezones. For example, I set my TZ to PST, GMT and the values were correct. I debugged little further and found that the value is changed in the following code: Calendar c = new GregorianCalendar(); c.set(Calendar.ERA, 1); c.set(Calendar.YEAR, 2009); c.set(Calendar.MONTH, 4-1); c.set(Calendar.DAY_OF_MONTH, 15); c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); Timestamp ts = new Timestamp(c.getTime().getTime()); In the specific scenario, if you print ts, it shows hour value as 1 only on this specific date. So obviously, something seems wrong with JDK or my timezone data. My point is, that when we don't want the value interpreted in different timezones (we are using timestamp and not timestamp with timezone), we should not use Calander to convert value to a timestamp when we exactly have year,month,day,hour,minute and second values. -- Altaf Malik ________________________________ From: Kevin Grittner To: Altaf Malik Cc: Samuel Gendler ; pgsql-jdbc@postgresql.org Sent: Fri, January 7, 2011 2:00:55 AM Subject: Re: [JDBC] Strange behaviour of rs.getTimestamp Samuel Gendler wrote: > It might also be potentially revealing if you print out the > default timezone and locale for the jvm in question as well. Good point. In addition to the system properties printed from what I posted, please include the "user.timezone" system property. -Kevin -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc --0-1620441473-1294414286=:28558 Content-Type: text/html; charset=us-ascii
Here is the output of the program run. I also included user.timezone

Sun Microsystems Inc.
1.6.0_21
Java HotSpot(TM) 64-Bit Server VM
mixed mode
TimeZone:Asia/Karachi
2009-04-15 00:00:00->2009-04-15 01:00:00.0

I am using UBUNTU 10.10 64 bit.
I don't see this behaviour with other timezones. For example, I set my TZ to PST, GMT and the values were correct.

I debugged little further and found that the value is changed in the following code:

    Calendar c = new GregorianCalendar();
        c.set(Calendar.ERA,          1);
        c.set(Calendar.YEAR,         2009);
        c.set(Calendar.MONTH,        4-1);
        c.set(Calendar.DAY_OF_MONTH, 15);
        c.set(Calendar.HOUR_OF_DAY,  0);
        c.set(Calendar.MINUTE,       0);
        c.set(Calendar.SECOND,       0);
        c.set(Calendar.MILLISECOND,  0);
        Timestamp ts = new Timestamp(c.getTime().getTime());

In the specific scenario, if you print ts, it shows hour value as 1 only on this specific date. So obviously, something seems wrong with JDK or my timezone data.
My point is, that when we don't want the value interpreted in different timezones (we are using timestamp and not timestamp with timezone), we should not  use Calander to convert value to a timestamp when we exactly have year,month,day,hour,minute and second values.

-- Altaf Malik


From: Kevin Grittner <Kevin.Grittner@wicourts.gov>
To: Altaf Malik <mmalik_altaf@yahoo.com>
Cc: Samuel Gendler <sgendler@ideasculptor.com>; pgsql-jdbc@postgresql.org
Sent: Fri, January 7, 2011 2:00:55 AM
Subject: Re: [JDBC] Strange behaviour of rs.getTimestamp

Samuel Gendler <sgendler@ideasculptor.com> wrote:

> It might also be potentially revealing if you print out the
> default timezone and locale for the jvm in question as well.

Good point.  In addition to the system properties printed from what
I posted, please include the "user.timezone" system property.

-Kevin

--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc

--0-1620441473-1294414286=:28558--