File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes ResultSet getDate conversion to Util Date? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Reply 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
internet detective
Marshal

Joined: May 26, 2003
Posts: 26496
    
  78

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ResultSet getDate conversion to Util Date?
 
Similar Threads
server date
Date function
date and time in sql
how to get system date
Enterprise application: handling date and time