• Post Reply Bookmark Topic Watch Topic
  • New Topic

Mapping Oracle Date/Time to Java types.

 
Greg Charles
Sheriff
Posts: 3012
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Sheriff
Posts: 36032
432
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!