Re: Timestamp vs. Java Date/Timestamp

Поиск
Список
Период
Сортировка
От Dave Cramer
Тема Re: Timestamp vs. Java Date/Timestamp
Дата
Msg-id CADK3HHKPL5YbOVnQoP__E362qzVedgLXOmfDBfBcfzX4Sntp-Q@mail.gmail.com
обсуждение исходный текст
Ответ на Timestamp vs. Java Date/Timestamp  (Andreas Reichel <andreas@manticore-projects.com>)
Ответы Re: Timestamp vs. Java Date/Timestamp  (dmp <danap@ttc-cmc.net>)
Список pgsql-jdbc


On Wed, Feb 13, 2013 at 12:37 AM, Andreas Reichel <andreas@manticore-projects.com> wrote:
Dave,

please find a test attached. I guess, I can shed some light on it in the
meantime.

To me it seems, that setDate()/getDate() indeed ignores any time values
(hh:mm:ss.s) but parses the day-part only (yyyy-mm-dd).
At the same time, setTimestamp()/getTimestamp() behaves correctly.

(Note: in Postgres Date is Date only without Time, while Timestamp obeys
the Time, I was not completely aware of this. I thought the only
difference between Date and Timestamp is Milliseconds vs. Nanoseconds.)


And this is the crux of the matter SQL DATE does not have time in it. While java.sql.Date being derived from java.util.Date does.
 
On the same time java.sql.Date and java.util.Date support time
information and in fact you can handover a java.sql.Date parameter to a
Timestamp field.

This is the part when I get confused: the timestamp field holds time
information, the java.sql.Date parameter holds time information -- still
it is cut off in the middle.


Now I would like to suggest a couple of small changes:
a) allow java.util.Date in setObject() and convert it into
java.sql.Timestamp automatically
b) keep the time info whenever setting/returning java.sql.Date to/from a
Timestamp field

However, for the moment I am fine as I understood now the need for using
java.sql.Timestamp when working with time.


And I think that is the way it will remain. I'm afraid this would break way more than it would fix



Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Craig Ringer
Дата:
Сообщение: Re: [HACKERS] JPA + enum == Exception
Следующее
От: Heikki Linnakangas
Дата:
Сообщение: Re: PostgreSQL XAResource & GlassFish 3.1.2.2