aspose file tools*
The moose likes JDBC and the fly likes ResultSet getDate conversion to Util Date? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "ResultSet getDate conversion to Util Date?" Watch "ResultSet getDate conversion to Util Date?" New topic
Author

ResultSet getDate conversion to Util Date?

Peter White
Greenhorn

Joined: Sep 21, 2006
Posts: 14
Is it a general practice to do something like the following:

java.util.Date myDate = new java.util.Date(rs.getDate(col).getTime());

Or is there a better technique? I read somewhere that doing the above might change the date because of a nanosecond bug in Java?

Thanks

Peter


Building a new game one brick at a time.<br /><a href="http://whitehexagon.com" target="_blank" rel="nofollow">http://whitehexagon.com</a>
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30966
    
158

Peter,
That's what I've always used. I haven't had any conversion problems, but that doesn't mean there isn't a problem.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Peter White
Greenhorn

Joined: Sep 21, 2006
Posts: 14
I think the issue I saw was maybe more to do with sybase only storing fractions of seconds. Basically I was getting a slightly different date back from what I was storing.

Thanks

Peter
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: ResultSet getDate conversion to Util Date?