Current Timestamp In Java
Chapter:
Date and Time
Last Updated:
23-09-2016 07:40:43 UTC
Program:
/* ............... START ............... */
import java.sql.Timestamp;
import java.util.Date;
public class JavaCurrentTimeStamp {
public static void main(String[] args) {
Date date = new Date();
Timestamp timestamp = new Timestamp(date.getTime());
System.out.println(timestamp);
}
}
/* ............... END ............... */
Output
Notes:
-
You will get current time in milliseconds by calling getTime() method of Date.
Tags
Current Timestamp, Java, Date And Time