Re: Bug? report : PreparedStatement.setObject(java.util.Date) don't work

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: 雨森郷太郎 <gotaroamenomori(at)gmail(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Bug? report : PreparedStatement.setObject(java.util.Date) don't work
Date: 2007-11-10 09:28:56
Message-ID: 473579D8.3060600@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

雨森郷太郎 wrote:

> However, Is there reason to refrain from supporting java.util.Date ?

Despite the name, java.util.Date actually contains both date and time
information, and mapping it to SQL's DATE would silently lose data.
That's why java.sql.Date exists in the first place: it's a deliberately
limited subclass that explicitly only carries date information.

We could map java.util.Date to TIMESTAMP, I suppose, but I think that'll
cause even more confusion since there's also java.sql.Timestamp (that
gives nanosecond precision vs. java.util.Date's millisecond precision).
Most of the time, using java.util.Date with JDBC means you've got an
application bug, and I don't think silently covering it up is a great idea.

-O

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message 雨森郷太郎 2007-11-10 10:10:59 Re: Bug? report : PreparedStatement.setObject(java.util.Date) don't work
Previous Message 雨森郷太郎 2007-11-10 05:24:23 Re: Bug? report : PreparedStatement.setObject(java.util.Date) don't work