Java examples for Date Time:Legacy Date
Using the Date Class
import java.util.Date; public class Main { public static void main (String[] args) { // Create a new Date object Date currentDate = new Date(); System.out.println("Current date: " + currentDate); //from ww w . ja v a 2 s . co m // Get the milliseconds value of the current date long millis = currentDate.getTime(); System.out.println("Current datetime in millis: " + millis); } }