Re: using Date and setObject()

From: "Joe Shevland" <jshevland(at)j-elite(dot)com>
To: "Thomas O'Dowd" <tom(at)nooper(dot)com>, "Leandro Rodrigo Saad Cruz" <leandro(at)ibnetwork(dot)com(dot)br>
Cc: <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: using Date and setObject()
Date: 2002-04-18 05:48:29
Message-ID: HEECIHEEJDBMCCGMGIOBMECOCHAA.jshevland@j-elite.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

The big difference is of course, is that the java.sql.Date is "A thin wrapper around a millisecond value that allows JDBC to identify this as a SQL DATE (JDK1.3.1 doco)" - it subclasses java.util.Date so certainly holds time ;)

In relation before that, java.util.Date holds a specific instance in time - without timezones coming into play - in reality the amount of seconds since Unix birth or 1970 or whatever it is. I'm not sure about the JDBC driver and backend interaction, but I'd be using a GregorianCalendar or Calendar instance instead, which is more suitable for manipulating dates and times. I'm not sure if the setObject() method caters for this though.

Cheers,
Joe

> Never tried it but what about using setObject(java.sql.Date)
> ^^^
>
> The big difference between the objects of course is that the
> java.sql.Date only holds the date part and not the time part.
>
> Tom.
>
> On Wed, Apr 17, 2002 at 02:53:43PM -0300, Leandro Rodrigo Saad Cruz wrote:
> > Hi all, I'm working an a persistence layer API above JDBC
> > that uses setObject() in prepare statements. the problem is :
> > I get a ClassCastException when using setObject(java.util.Date).
> > Can I use setObject(java.util.Date) or I **must** use
> > setDate(java.util.Date) ??
> >
> > --
> > Leandro Rodrigo Saad Cruz
> > IT - Inter Business Tecnologia e Servicos (IB)
> > http://www.ibnetwork.com.br

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Joe Shevland 2002-04-18 05:49:29 Re: BLOB performance test FYI
Previous Message Joe Shevland 2002-04-18 04:49:14 Re: BLOB performance test FYI