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 Mapping Oracle Date/Time to Java types. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Mapping Oracle Date/Time to Java types." Watch "Mapping Oracle Date/Time to Java types." New topic
Author

Mapping Oracle Date/Time to Java types.

Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2849
    
  11

We're using Oracle 9i (9.2.0.6) as our database, JDK 1.4.2, and Firestorm DAO to build our O/R mapping classes. The latest set of classes used java.sql.Date in queries to retrieve information from an Oracle DATE field, but I was forced to change it to use a java.sql.Timestamp instead. My understanding is Oracle DATE retains date and time info to the second, java.sql.Date to the millisecond, and java.sql.Timestamp (in theory) to the nanosecond. However, until I started using Timestamp, my DTOs all ended up with dates only, the time reset to midnight GMT. I'm confused. Why did that happen?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30392
    
150

Originally posted by Greg Charles:
My understanding is Oracle DATE retains date and time info to the second, java.sql.Date to the millisecond, and java.sql.Timestamp (in theory) to the nanosecond.

getDate() only stores the date values. getTime() stores the time values. getTimestamp() stores both.


[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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mapping Oracle Date/Time to Java types.