Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 14D241337B92 for ; Fri, 7 Jan 2011 14:49:25 -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 37516-03 for ; Fri, 7 Jan 2011 18:49:16 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from flawless.hostnac.com (flawless.hostnac.com [67.23.244.186]) by mail.postgresql.org (Postfix) with ESMTP id E4AFC1337BA4 for ; Fri, 7 Jan 2011 14:49:11 -0400 (AST) Received: from 87-204-194-135.dg-net.pl ([87.204.194.135]:55049 helo=radek.localnet) by flawless.hostnac.com with esmtpa (Exim 4.69) (envelope-from ) id 1PbHN5-0001lt-La; Fri, 07 Jan 2011 13:49:08 -0500 From: =?utf-8?q?Rados=C5=82aw_Smogura?= To: pgsql-jdbc@postgresql.org Subject: Re: Strange behaviour of rs.getTimestamp Date: Fri, 7 Jan 2011 19:49:04 +0100 User-Agent: KMail/1.13.5 (Linux/2.6.36-gentoo-r5; KDE/4.4.5; x86_64; ; ) Cc: Altaf Malik , Kevin Grittner , Samuel Gendler References: <416690.93407.qm@web110406.mail.gq1.yahoo.com> <948897.28558.qm@web110410.mail.gq1.yahoo.com> <201101071754.52152.rsmogura@softperience.eu> In-Reply-To: <201101071754.52152.rsmogura@softperience.eu> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <201101071949.04842.mail@smogura.eu> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - flawless.hostnac.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - smogura.eu X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201101/21 X-Sequence-Number: 21353 Sorry, but for P. S. It's quite good response, because, in your timezone, and in all other=20 timezones when DST starts there is no hour and times in your e.g. 2009-14-1= 5=20 0:00:00 till 2099-14-15 1:00:00. At midnight you add one hour to all clocks= =2E=20 So just after 2009-14-14 23:59:59.9999999. you have 2009-14-15 1:0:0. As you use Timestamps, Java internaly stores time in UTC, and when You cast= =20 this to String, then Calendar will rollover such fields to next Value (see= =20 setLenient(bool)). Unfortunatly Pakistan Gover, choosed realy bed time for DST, if this would = be=20 1 AM, you have no problem. Rados=C5=82aw Smogura Friday 07 January 2011 17:= 54:51 > Hi, > I think it's DST maybe you missed something. I didn't search deaply. > https://bugzilla.redhat.com/show_bug.cgi?id=3D495473 >=20 > Did you missed something, about DST? >=20 > Kind regards, > Rados=C5=82aw Smogura > http://softperience.eu >=20 > Altaf Malik Friday 07 January 2011 16:31:26 >=20 > > Here is the output of the program run. I also included user.timezone > >=20 > > 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 > >=20 > > 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. > >=20 > >=20 > > I debugged little further and found that the value is changed in the > >=20 > > following code: > > Calendar c =3D new GregorianCalendar(); > > =20 > > 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); > > =20 > > c.set(Calendar.MILLISECOND, 0); > > =20 > > Timestamp ts =3D new Timestamp(c.getTime().getTime()); > >=20 > > In the specific scenario, if you print ts, it shows hour value as 1 on= ly > > on this specific date. So obviously, something seems wrong with JDK or= =20 > > my timezone data. > >=20 > > 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 exact= ly > > have year,month,day,hour,minute and second values. > >=20 > > -- Altaf Malik > >=20 > >=20 > >=20 > > ________________________________ > > From: Kevin Grittner > > To: Altaf Malik > > Cc: Samuel Gendler ; pgsql-jdbc@postgresql.o= rg > > Sent: Fri, January 7, 2011 2:00:55 AM > > Subject: Re: [JDBC] Strange behaviour of rs.getTimestamp > >=20 > > 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. > >=20 > > Good point. In addition to the system properties printed from what > > I posted, please include the "user.timezone" system property. > >=20 > > -Kevin