DEVFYI - Developer Resource - FYI

How can I tell if my JDBC driver normalizes java.sql.Date and java.sql.Time objects?

JDBC Interview Questions and Answers


(Continued from previous question...)

How can I tell if my JDBC driver normalizes java.sql.Date and java.sql.Time objects?

To actually determine the values, the objects must be converted to a java.util.Date and examined. See What does normalization mean for java.sql.Date and java.sql.Time? for the definition of normalization. Notice that even a debugger will not show whether these objects have been normalized, since the getXXX methods in java.sql.Date for time elements and in java.sql.Time for date elements throw an exception.
So, while a java.sql.Date may show 2001-07-26, it's normalized only if the java.util.Date value is:
Thu Jul 26 00:00:00 EDT 2001
and while a java.sql.Time may show 14:01:00, it's normalized only if the java.util.Date value is:
Thu Jan 01 14:01:00 EST 1970

(Continued on next question...)

Other Interview Questions