import java.util.Calendar;
import java.util.Date;
import java.time.ZonedDateTime;
public class Example {
public static void main(String[] args)
{
Date date = new Date();
long timeMilli = date.getTime();
System.out.println("Time in milliseconds using Date class: " + timeMilli);
Calendar calendar = Calendar.getInstance();
long timeMilli2 = calendar.getTimeInMillis();
System.out.println("Time in milliseconds using Calendar: " + timeMilli2);
System.out.println("Getting time in milliseconds in Java 8: " +
ZonedDateTime.now().toInstant().toEpochMilli());
}
}