by Dinesh Thakur Category: Control Structures

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);
        Calendar cal = Calendar.getInstance();
        today = cal.getTime();

currentTimeMillis() Java Example

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Related Articles