[Pljava-dev] Has ResultSet.getDate() correct handling DayLight saving time?

Lists: PostgreSQL : PostgreSQL 메일 링리스트 : 2006-03-31 이후 무지개 토토Dev 03:16
From: carapuz at gmail(dot)com (Nic Nofamily)
To:
Subject: [Pljava-dev] Has ResultSet.getDate() correct handling DayLight saving time?
Date: 2006-03-30 20:04:42
Message-ID: ce6becd90603301204p4ad121dcna667b89621661b17@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pljava-dev

Hi all!
I have a little trouble with my pljava functions last night:(
--------------
here config:
Java HotSpot(TM) Server VM (build 1.5.0_06-b05, mixed mode)
Debian Sarge
pljava 1.2.0 compiled from source
postgresql 8.1.3 installed from debian backports
---------------
ResultSet.getDate for to_date('01/11/2005','DD/MM/YYYY') returns
31/10/2005 for pljava jdbc driver
the same java code using postgresql jdbc driver works fine:(

I discovered that wrong result depend on DayLight Saving time
and i wrote workaround on ObjectResultSet.getDate()

public Date getDate(int columnIndex)
throws SQLException
{
Date d = (Date)this.getValue(columnIndex,Date.class);
if(!java.util.TimeZone.getDefault().inDaylightTime(d)){
d = new
java.sql.Date(d.getTime()+java.util.TimeZone.getDefault().getDSTSavings());
}
return d;
}

now my pljava code works good, but that's wrong way:(
What are you comments, developers?:)
PS: sorry for my English,I am Russian:)


From: thomas at tada(dot)se (Thomas Hallgren)
To:
Subject: [Pljava-dev] Has ResultSet.getDate() correct handling DayLight saving time?
Date: 2006-03-30 20:54:45
Message-ID: 442C4595.60900@tada.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pljava-dev

Hi Nic,
I don't think the returned date as such is incorrect. The problem occurs
when you represent the date as a string. What timezone do you use when
you do that? Do you simply use d.toString() ? If so, the default
timezone for your JVM is incorrect and that's the source of the problem.

Regards,
Thomas Hallgren

Nic Nofamily wrote:
> Hi all!
> I have a little trouble with my pljava functions last night:(
> --------------
> here config:
> Java HotSpot(TM) Server VM (build 1.5.0_06-b05, mixed mode)
> Debian Sarge
> pljava 1.2.0 compiled from source
> postgresql 8.1.3 installed from debian backports
> ---------------
> ResultSet.getDate for to_date('01/11/2005','DD/MM/YYYY') returns
> 31/10/2005 for pljava jdbc driver
> the same java code using postgresql jdbc driver works fine:(
>
> I discovered that wrong result depend on DayLight Saving time
> and i wrote workaround on ObjectResultSet.getDate()
>
> public Date getDate(int columnIndex)
> throws SQLException
> {
> Date d = (Date)this.getValue(columnIndex,Date.class);
> if(!java.util.TimeZone.getDefault().inDaylightTime(d)){
> d = new
> java.sql.Date(d.getTime()+java.util.TimeZone.getDefault().getDSTSavings());
> }
> return d;
> }
>
> now my pljava code works good, but that's wrong way:(
> What are you comments, developers?:)
> PS: sorry for my English,I am Russian:)
> _______________________________________________
> Pljava-dev mailing list
> Pljava-dev at gborg.postgresql.org
> http://gborg.postgresql.org/mailman/listinfo/pljava-dev
>


From: carapuz at gmail(dot)com (Nic Nofamily)
To:
Subject: [Pljava-dev] Has ResultSet.getDate() correct handling DayLight saving time?
Date: 2006-03-31 02:40:07
Message-ID: ce6becd90603301840j1b423bedwd3bee51555620eb6@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pljava-dev

But d.getTime() return different values when I called the same code from pljava.jdbc and postgresql.jdbc on same machine with same JVM. The diff was 3600000 msek before for pljava.
:( TimeZone.getDefault() at both pljava.jdbc and postgresql.jdbc equals
---------
WBR, NiC

2006/3/31, Thomas Hallgren <thomas at tada.se>:
> Hi Nic,
> I don't think the returned date as such is incorrect. The problem occurs
> when you represent the date as a string. What timezone do you use when
> you do that? Do you simply use d.toString() ? If so, the default
> timezone for your JVM is incorrect and that's the source of the problem.
>
> Regards,
> Thomas Hallgren
>
> Nic Nofamily wrote:
> > Hi all!
> > I have a little trouble with my pljava functions last night:(
> > --------------
> > here config:
> > Java HotSpot(TM) Server VM (build 1.5.0_06-b05, mixed mode)
> > Debian Sarge
> > pljava 1.2.0 compiled from source
> > postgresql 8.1.3 installed from debian backports
> > ---------------
> > ResultSet.getDate for to_date('01/11/2005','DD/MM/YYYY') returns
> > 31/10/2005 for pljava jdbc driver
> > the same java code using postgresql jdbc driver works fine:(
> >
> > I discovered that wrong result depend on DayLight Saving time
> > and i wrote workaround on ObjectResultSet.getDate()
> >
> > public Date getDate(int columnIndex)
> > throws SQLException
> > {
> > Date d = (Date)this.getValue(columnIndex,Date.class);
> > if(!java.util.TimeZone.getDefault().inDaylightTime(d)){
> > d = new
> >
> java.sql.Date(d.getTime()+java.util.TimeZone.getDefault().getDSTSavings());
> > }
> > return d;
> > }
> >
> > now my pljava code works good, but that's wrong way:(
> > What are you comments, developers?:)
> > PS: sorry for my English,I am Russian:)
> > _______________________________________________
> > Pljava-dev mailing list
> > Pljava-dev at gborg.postgresql.org
> > http://gborg.postgresql.org/mailman/listinfo/pljava-dev
> >
>
>


From: carapuz at gmail(dot)com (Nic Nofamily)
To:
Subject: [Pljava-dev] Has ResultSet.getDate() correct handling DayLight saving time?
Date: 2006-03-31 03:16:56
Message-ID: ce6becd90603301916t6bd5aa29o6c4c2cad80dcde8f@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: PostgreSQL : PostgreSQL 메일 링리스트 : 2006-03-31 이후 무지개 토토Dev 03:16

And this code in Date.c

static jvalue _Date_coerceDatum(Type self, Datum arg)
{
jlong date = (jlong)(DatumGetDateADT(arg) + EPOCH_DIFF);

jvalue result;
date *= 86400L; // Convert to seconds
date += Timestamp_getCurrentTimeZone(); // Add local timezone
result.l = JNI_newObject(s_Date_class, s_Date_init, date * 1000);
return result;
}

date += Timestamp_getCurrentTimeZone(); // Add local timezone
may be so ????
date +=Timestamp_getCurrentTime(date);
--------------------
WBR, NiC

2006/3/31, Nic Nofamily <carapuz at gmail.com>:
> But d.getTime() return different values when I called the same code from
> pljava.jdbc and postgresql.jdbc on same machine with same JVM. The diff was
> 3600000 msek before for pljava.
> :( TimeZone.getDefault() at both pljava.jdbc and postgresql.jdbc equals
> ---------
> WBR, NiC
>
> 2006/3/31, Thomas Hallgren <thomas at tada.se>:
> > Hi Nic,
> > I don't think the returned date as such is incorrect. The problem occurs
> > when you represent the date as a string. What timezone do you use when
> > you do that? Do you simply use d.toString() ? If so, the default
> > timezone for your JVM is incorrect and that's the source of the problem.
> >
> > Regards,
> > Thomas Hallgren
> >
> > Nic Nofamily wrote:
> > > Hi all!
> > > I have a little trouble with my pljava functions last night:(
> > > --------------
> > > here config:
> > > Java HotSpot(TM) Server VM (build 1.5.0_06-b05, mixed mode)
> > > Debian Sarge
> > > pljava 1.2.0 compiled from source
> > > postgresql 8.1.3 installed from debian backports
> > > ---------------
> > > ResultSet.getDate for to_date('01/11/2005','DD/MM/YYYY') returns
> > > 31/10/2005 for pljava jdbc driver
> > > the same java code using postgresql jdbc driver works fine:(
> > >
> > > I discovered that wrong result depend on DayLight Saving time
> > > and i wrote workaround on ObjectResultSet.getDate()
> > >
> > > public Date getDate(int columnIndex)
> > > throws SQLException
> > > {
> > > Date d = (Date)this.getValue(columnIndex,Date.class);
> > > if(!java.util.TimeZone.getDefault().inDaylightTime(d)){
> > > d = new
> > >
> >
> java.sql.Date(d.getTime()+java.util.TimeZone.getDefault().getDSTSavings());
> > > }
> > > return d;
> > > }
> > >
> > > now my pljava code works good, but that's wrong way:(
> > > What are you comments, developers?:)
> > > PS: sorry for my English,I am Russian:)
> > > _______________________________________________
> > > Pljava-dev mailing list
> > > Pljava-dev at gborg.postgresql.org
> > > http://gborg.postgresql.org/mailman/listinfo/pljava-dev
> > >
> >
> >
>


From: thomas at tada(dot)se (Thomas Hallgren)
To:
Subject: [Pljava-dev] Has ResultSet.getDate() correct handling DayLight saving time?
Date: 2006-03-31 05:39:30
Message-ID: 442CC092.4070101@tada.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pljava-dev

Hi Nic,
Doh, you're right! The timezone is added correctly but I pick todays
timezone, not the timezone of the date in question. I'll get back to you
when that's fixed. Thanks for pointing this out (and keeping after me
when I claimed there was no problem).

Regards,
Thomas Hallgren

Nic Nofamily wrote:
> But d.getTime() return different values when I called the same code from pljava.jdbc and postgresql.jdbc on same machine with same JVM. The diff was 3600000 msek before for pljava.
> :( TimeZone.getDefault() at both pljava.jdbc and postgresql.jdbc equals
> ---------
> WBR, NiC
>
> 2006/3/31, Thomas Hallgren <thomas at tada.se>:
>
>> Hi Nic,
>> I don't think the returned date as such is incorrect. The problem occurs
>> when you represent the date as a string. What timezone do you use when
>> you do that? Do you simply use d.toString() ? If so, the default
>> timezone for your JVM is incorrect and that's the source of the problem.
>>
>> Regards,
>> Thomas Hallgren
>>
>> Nic Nofamily wrote:
>>
>>> Hi all!
>>> I have a little trouble with my pljava functions last night:(
>>> --------------
>>> here config:
>>> Java HotSpot(TM) Server VM (build 1.5.0_06-b05, mixed mode)
>>> Debian Sarge
>>> pljava 1.2.0 compiled from source
>>> postgresql 8.1.3 installed from debian backports
>>> ---------------
>>> ResultSet.getDate for to_date('01/11/2005','DD/MM/YYYY') returns
>>> 31/10/2005 for pljava jdbc driver
>>> the same java code using postgresql jdbc driver works fine:(
>>>
>>> I discovered that wrong result depend on DayLight Saving time
>>> and i wrote workaround on ObjectResultSet.getDate()
>>>
>>> public Date getDate(int columnIndex)
>>> throws SQLException
>>> {
>>> Date d = (Date)this.getValue(columnIndex,Date.class);
>>> if(!java.util.TimeZone.getDefault().inDaylightTime(d)){
>>> d = new
>>>
>>>
>> java.sql.Date(d.getTime()+java.util.TimeZone.getDefault().getDSTSavings());
>>
>>> }
>>> return d;
>>> }
>>>
>>> now my pljava code works good, but that's wrong way:(
>>> What are you comments, developers?:)
>>> PS: sorry for my English,I am Russian:)
>>> _______________________________________________
>>> Pljava-dev mailing list
>>> Pljava-dev at gborg.postgresql.org
>>> http://gborg.postgresql.org/mailman/listinfo/pljava-dev
>>>
>>>
>>
> _______________________________________________
> Pljava-dev mailing list
> Pljava-dev at gborg.postgresql.org
> http://gborg.postgresql.org/mailman/listinfo/pljava-dev
>