Tuesday, January 5, 2010

How to get time information in java.sql.Date?

The answser is you cannot.
java.sql.Date does not store/retrieve any information related to time.

So, how do you solve the problem of saving the date with time in your database?

Simple… use java.sql.Timestamp. There are methods in java.sql.PreparedStatement and java.sql.Statement to set the timestamp.

No comments: