pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Radosław Smogura <mail@smogura.eu>
To: pgsql-jdbc@postgresql.org
Cc: Altaf Malik <mmalik_altaf@yahoo.com>
Cc: Kevin Grittner <Kevin.Grittner@wicourts.gov>
Cc: Samuel Gendler <sgendler@ideasculptor.com>
Subject: Re: Strange behaviour of rs.getTimestamp
Date: Fri, 7 Jan 2011 19:49:04 +0100
Message-ID: <201101071949.04842.mail@smogura.eu> (raw)
In-Reply-To: <201101071754.52152.rsmogura@softperience.eu>
References: <416690.93407.qm@web110406.mail.gq1.yahoo.com>
	<948897.28558.qm@web110410.mail.gq1.yahoo.com>
	<201101071754.52152.rsmogura@softperience.eu>

Sorry, but for P. S.

It's quite good response, because, in your timezone, and in all other 
timezones when DST starts there is no hour and times in your e.g. 2009-14-15 
0:00:00 till 2099-14-15 1:00:00. At midnight you add one hour to all clocks. 
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 
this to String, then Calendar will rollover such fields to next Value (see 
setLenient(bool)).

Unfortunatly Pakistan Gover, choosed realy bed time for DST, if this would be 
1 AM, you have no problem.

Radosław Smogura <rsmogura@softperience.eu> 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=495473
> 
> Did you missed something, about DST?
> 
> Kind regards,
> Radosław Smogura
> http://softperience.eu
> 
> Altaf Malik <mmalik_altaf@yahoo.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.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



view thread (8+ messages)

Message-ID: <201101071949.04842.mail@smogura.eu>
Permalink:  ../201101071949.04842.mail@smogura.eu/
Also on:    postgresql.org/message-id/201101071949.04842.mail@smogura.eu

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: mail@smogura.eu, mmalik_altaf@yahoo.com, Kevin.Grittner@wicourts.gov, sgendler@ideasculptor.com
  Subject: Re: Strange behaviour of rs.getTimestamp
  In-Reply-To: <201101071949.04842.mail@smogura.eu>
  References: <416690.93407.qm@web110406.mail.gq1.yahoo.com> <948897.28558.qm@web110410.mail.gq1.yahoo.com> <201101071754.52152.rsmogura@softperience.eu> <201101071949.04842.mail@smogura.eu>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox