Convert date value to long value in milliseconds

ReturnMethodSummary
longgetTime()Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object.
voidsetTime(long time)Sets this Date object to represent a point in time that is time milliseconds after January 1, 1970 00:00:00 GMT.

Convert Date into milliseconds


import java.util.Date;

public class Main {
  public static void main(String args[]) {
 
    Date date = new Date();
    System.out.println("Date is : " + date);
 
    System.out.println("Milliseconds since January 1, 1970, 00:00:00 GMT : "
        + date.getTime());
  }
}

The output:


Date is : Sat Oct 30 09:17:52 PDT 2010
Milliseconds since January 1, 1970, 00:00:00 GMT : 1288455472578
java2s.com  |  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.