Convert Date into milliseconds - Java Date Time

Java examples for Date Time:Legacy Date

Description

Convert Date into milliseconds

Demo Code


import java.util.*;
 
public class Main {
 
  public static void main(String args[]){
      Date date = new Date();
      System.out.println("Date is : " + date);
     //from   w  w w  . j av a2  s  . c o  m
      //use getTime() method to retrieve milliseconds
      System.out.println("Milliseconds since January 1, 1970, 00:00:00 GMT : "
                          + date.getTime());
   
  }
 
}

Result


Related Tutorials