Get time in milliseconds using Calendar in Java

Description

The following code shows how to get time in milliseconds using Calendar.

Example


/*from   w ww  .j a  v a2 s.  co  m*/
import java.util.Calendar;

public class Main {

  public static void main(String[] args) {
    Calendar now = Calendar.getInstance();
    System.out.println("Current milliseconds since Jan 1, 1970 are :" + now.getTimeInMillis());

  }

}

The code above generates the following result.





















Home »
  Java Tutorial »
    Date »




Date Get
Date Set
Date Format
Date Compare
Date Convert
Date Calculation
Date Parse
Timezone