How to convert java.util.Date to java.sql.Timestamp?
You can convert a java.util.Date to java.sql.Timestamp value by using the getTime() method of Date class. This method return the long millisecond value from Epoch (1st January 1970 midnight) which you can pass to java.sql.Timestamp to create a new instance of Timestamp object in JDBC. Remember, java.sql.TimeStamp class is a wrapper around java.util.Date to allow JDBC to view it as SQL TIMESTAMP value. Only way to create a Timestamp instance is by passing the long time value because the second constructor of Timestamp class, which accepts individual fields e.g. year, month, date, hour, minute, second and nano is deprecated. Timestamp class can also hold up-to nano second value.
Read more �
Comments
Post a Comment
-Berkomentarlah yang baik dan rapi.
-Menggunakan link aktif akan dihapus.