Java Date Time - Java Date.getTime()








Syntax

Date.getTime() has the following syntax.

public long getTime()

Example

In the following code shows how to use Date.getTime() method.

//from   w ww  .j  a v  a2 s . co  m

import java.util.Date;

public class Main {

   public static void main(String[] args) {

      Date date = new Date();
      long diff = date.getTime();

      System.out.println(diff);

   }
}

The code above generates the following result.