Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Setting an sql.Date or Timestamp to time 0 => strange results

807589Oct 29 2008 — edited Nov 5 2008
I am encountering a problem someone mentioned before (archived thread, but without solution).

I tried to set an sql.Date and a Timestamp to 0 (meaning all timeattributes = 0). Per definition,
that is a violation of the value range within the Timestamp (count from 1970) but not for the
sql.Date.

so I tried:
Date d = Date.valueOf("0000-00-00");       // 0002-11-30
Timestamp t = Timestamp.valueOf("0000-00-00 00:00:00.000000000");      // 0002-11-30 00:00:00.0
Can anyone explain to me these results?
Some other thoughts came to my mind:

1. a Timestamp should not accept this value at all (?!)
2. The sql.Date offers two Constructors. The first (year, month, day) is deprecated so I don't want
to use it. The second (milliseconds) counts from 1970 - sure, you can use negative time to get to
a date earlier than 1970, but this is very uncomfortable
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 3 2008
Added on Oct 29 2008
4 comments
1,823 views