by Dinesh Thakur

The currentTimeMillis() method returns the current time in milliseconds since 00:00:00,January I, 1970.This method is used to know the time interval a process or job takes to perform. We record the time before and after the operation and the difference of two timings tells us the total time the operation took.

import java.util.Calendar;
import java.util.Date;
public class currentTimeMillisExample
{
    public static void main( String[] args)
    {
        long t = System.currentTimeMillis();
        Date today = new Date(t);
        System.out.println(t);
        System.out.println(today);
        Calendar cal = Calendar.getInstance();
        today = cal.getTime();
        System.out.println(today);
    }
}

currentTimeMillis() Java Example