Re: Storing timestamps in text format

From: Radosław Smogura <rsmogura(at)softperience(dot)eu>
To: Oliver Jowett <oliver(at)opencloud(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Storing timestamps in text format
Date: 2010-12-02 05:33:08
Message-ID: 201012020633.08702.rsmogura@softperience.eu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Oliver Jowett <oliver(at)opencloud(dot)com> Thursday 02 December 2010 00:25:35
> Radosław Smogura wrote:
> > Hi,
> >
> > I perform following test:
> > 1. Open connection (GMT+1)
> > 2. Change timezone (GMT+3)
> > 3. Write created timestamp.
> > 4. Change timezone to different connection open and write (GMT+4)
> > 5. Read timezone
> >
> > During this I saw driver sends timestamp encoded with initial (in my case
> > +1), form connection open, time zone. It's because
> > TimestampUtils.toString(Calendar, Timestamp) uses defaultCal. Should it
> > use Calendar.getInstance() or new GregorianCalendar?
> >
> > public synchronized String toString(Calendar cal, Timestamp x) {
> >
> > if (cal == null)
> >
> > cal = defaultCal; // = Calendar.getInstance() // new
> >
> > GregorianCalendar()
>
> There seems to be some confusion about what the bug you are reporting
> actually is.
>
> Is the bug that if you change the JVM's default timezone halfway through
> a run, the change is not reflected in the driver? (i.e. defaultCal is
> initialized once only). Or is it something else?

Yes, problem is when I change default timezone during run.
> I vaguely remember that when writing this code, getting the default
> calendar was quite expensive..
> Oliver

Creating Gregorian Calendar, without fields set in constructir is realy
expensive. To address this we can use {TimeZone, Local} -> GregCal thread
local map, or this what I thinking about is to create new
GC(0,0,0).setTime(....);

--
----------
Radosław Smogura
http://www.softperience.eu

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message marcofoc@libero.it 2010-12-02 06:26:29 Driver work slow with new upgrade of Openjdk in Ubuntu
Previous Message Zhipan Wang 2010-12-02 05:14:46 ResultSet problem in JDBC