Re: Strange behaviour of rs.getTimestamp

From: Radosław Smogura <rsmogura(at)softperience(dot)eu>
To: pgsql-jdbc(at)postgresql(dot)org
Cc: Altaf Malik <mmalik_altaf(at)yahoo(dot)com>, Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>, Samuel Gendler <sgendler(at)ideasculptor(dot)com>
Subject: Re: Strange behaviour of rs.getTimestamp
Date: 2011-01-07 16:54:51
Message-ID: 201101071754.52152.rsmogura@softperience.eu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi,
I think it's DST maybe you missed something. I didn't search deaply.
https://bugzilla.redhat.com/show_bug.cgi?id=495473

Did you missed something, about DST?

Kind regards,
Radosław Smogura
http://softperience.eu

Altaf Malik <mmalik_altaf(at)yahoo(dot)com> Friday 07 January 2011 16:31:26
> 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(dot)Grittner(at)wicourts(dot)gov>
> To: Altaf Malik <mmalik_altaf(at)yahoo(dot)com>
> Cc: Samuel Gendler <sgendler(at)ideasculptor(dot)com>; pgsql-jdbc(at)postgresql(dot)org
> Sent: Fri, January 7, 2011 2:00:55 AM
> Subject: Re: [JDBC] Strange behaviour of rs.getTimestamp
>
> Samuel Gendler <sgendler(at)ideasculptor(dot)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

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Maciek Sakrejda 2011-01-07 17:28:47 Re: text type handling
Previous Message Altaf Malik 2011-01-07 15:31:26 Re: Strange behaviour of rs.getTimestamp