Re: JDBC/TIMESTAMP/infnity question

From: "Moran, William" <William(dot)Moran(at)intermedix(dot)com>
To: "Moran, William" <William(dot)Moran(at)intermedix(dot)com>, "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: JDBC/TIMESTAMP/infnity question
Date: 2014-03-11 15:25:18
Message-ID: 4D557EC7CC2A544AA7C1A3B9CBA2B36724E70E538B@exchange03.epbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc


For anyone who happens to find this via google search:

I did a little research and experimenting and found the answer. Java
doesn't include the era in the String version of the date by default,
so in the example below, the date of 292269055-12-02 is actually BC,
which is pretty reasonable.

> Working with the JDBC driver and PostgreSQL TIMESAMP types, I've
> observed the following behavior, which is odd to me:

> getString('infinity'::timestamp) = "infinity"
> getString('-infinity'::timestamp) = "-infinity"
> getTimestamp('infinity'::timestamp) = 292278994-08-16 18:00:00.0
> getTimestamp('-infinity'::timestamp) = 292269055-12-02 18:00:00.0

> As best as my research can tell, the java.sql.Timestamp type doesn't
> have any concept of infinity/-infinity. But I'm surprised -infinity
> is converted into a date far in the future instead of something in the
> past.

> Looking through the source code, it looks like the driver is trying to
> do the best it can by picking a large date in the past ... does anyone
> know why it's ending up in the future?

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2014-03-11 16:06:20 Re: Re: A prepared statement ERROR due to EMPTY_QUERY is defined as a static Instance.
Previous Message David Johnston 2014-03-11 01:22:47 Re: A prepared statement ERROR due to EMPTY_QUERY is defined as a static Instance.