Java Date convert to milliseconds

Description

Java Date convert to milliseconds

import java.util.Date;

public class Main {

  public static void main(String args[]) {
    Date date = new Date();
    System.out.println("Date is : " + date);

    // use getTime() method to retrieve milliseconds
    System.out.println("Milliseconds since January 1, 1970, 00:00:00 GMT : " + date.getTime());

  }/*from ww w.  j  a v a 2 s. co m*/

}



PreviousNext

Related