Convert Timestamp to Date in Java?
A thin wrapper around java.util.Date that allows the JDBC API to identify this as an SQL TIMESTAMP value. It adds the ability to hold the SQL TIMESTAMP fractional seconds value, by allowing the specification of fractional seconds to a precision of nanoseconds. As we know, JDBC DATE , JDBC TIME and JDBC TIMESTAMP are the three JDBC types related to date/time.
The JDBC API uses separate Date, Time and Timestamp class to confirm DATE, TIME and DATETIME data type from the database, but most of the Java object oriented code is written in java.util.Date . JDBC TIMESTAMP type represents DATE plus TIME plus a nanosecond field. The standard Java class java.util.Date does not exactly match with JDBC TIMESTAMP type because java.util.Date includes both DATE and TIME information but does not have nanoseconds. So we need a date-time type to map with JDBC TIMESTAMP . You can do by using the getTime() method, which return the number of millisecond from Epoch value. The following Java program just make a new Date object with the stamp's getTime value as a parameter.