In this section, you will learn to convert a date into a timestamp format.
Convert Date to Timestamp
In this section, you will learn to convert a date into a timestamp format.
Description of program:
The following program helps you in converting a date into timestamp format. The java.sql.Timestamp class is 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 value in nanoseconds. It also provides formatting and parsing operations to support the JDBC escape syntax for timestamp values. In this example we are just passing the time into an object of java.sql.Timestamp class as an argument.
Here is the code of program:
import java.util.*;
|
Output of this program:
C:\date>javac DateToMilliseconds.java C:\date>java DateToMilliseconds Today is 1181648109265 |