InformationPhotography |
Thursday, August 3. 2006Java Time Handling IssuesTrackbacks
Trackback specific URI for this entry
No Trackbacks
Comments
Display comments as
(Linear | Threaded)
This issue gets even richer. It turns out java.sql.Timestamp is really just a thin wrapper around java.util.Date. They do have the same precision, but it is broken and doesn't work right.
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4971405 http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5103041 What appeared to be happening in my case was Hibernate doing a compare between the Timestamp and the Date, which should have worked, but didn't.
This may be a bit late to help you, but not seeing your data, I would consider storing both dates in the database so you have them for future use instead of just storing a time delta.
To get the time delta, how you would want to approach it would depend on the resolution of time needed. If you need full precision, for example, just use the Date.getTime() function and do a subtraction between the longs, storing that value. If you need number of days, weeks, etc. check out java.util.GregorianCalendar. |
QuicksearchLexiyntax @ Twitter
Categories |