aspose file tools
The moose likes JDBC and Relational Databases 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


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
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: 32299
    
213

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.


[OCA 8 book] [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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ResultSet getDate conversion to Util Date?
 
It's not a secret anymore!