This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
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 Building Microservices this week in the Design 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: 32508
    
214

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]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, 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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: ResultSet getDate conversion to Util Date?
 
It's not a secret anymore!