We would like to know how to convert Date to timestamp.
import java.sql.Timestamp; import java.util.Date; // w w w .jav a2 s.co m public class Main { public static void main(String[] args) throws Exception { Date date = new Date(); System.out.println("Format To times:"); System.out.println(date.getTime()); Timestamp ts = new Timestamp(date.getTime()); System.out.println(ts); } }
The code above generates the following result.