pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gil G <gm12345678@gmail.com>
To: pgsql-jdbc@postgresql.org
Subject: TimestampUtils.loadCalendar failes for interval type
Date: Thu, 8 Sep 2005 14:26:23 +0300
Message-ID: <5a59b8db0509080426438d4370@mail.gmail.com> (raw)

Hi,

I've executed following query: 
select t.date-t.date2 from table as t

The query should return a single row of type interval. Indeed, 
resultSet.getObject(1) returns a PGInterval instance with the correct value 
(the returned interval is 2 days and several hours).

When I call resultSet.getString(1) the string representation of interval is 
"2 days 14:08:55.8246".
The problem arises when I call resultSet.getTimestamp(1). 
As I saw in org.postgresql.jdbc2.TimestampUtils.loadCalendar(GregorianCalendar 
cal, String s, String type) it fails to parse correctly 
the string, which is returned by resultSet.getString(1) call. since it 
expects only the "14:08:55.8246" part and does not expect the "2 days " part. 
Please note that in case the interval between two dates is smaller than 24 
hours everything works correctly. 

This is important since, generic products such as Hibernate that work over 
different jdbc drivers, refer to the interval data type as a 
java.sql.Timestamp object and call getTimestamp(int) method on the resultset 
to get the instance.

Thanks,
Gil

view thread (3+ messages)  latest in thread

Message-ID: <5a59b8db0509080426438d4370@mail.gmail.com>
Permalink:  ../5a59b8db0509080426438d4370@mail.gmail.com/
Also on:    postgresql.org/message-id/5a59b8db0509080426438d4370@mail.gmail.com

 · 

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: gm12345678@gmail.com
  Subject: Re: TimestampUtils.loadCalendar failes for interval type
  In-Reply-To: <5a59b8db0509080426438d4370@mail.gmail.com>
  References: <5a59b8db0509080426438d4370@mail.gmail.com>

* 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