Convert java.util.Date to long in Java
Description
The following code shows how to convert java.util.Date to long.
Example
// w w w . jav a2 s. c om
import java.util.Date;
public class Main {
public static void main(String args[]) {
Date date = new Date();
System.out.println(date);
long msec = date.getTime();
System.out.println("Milliseconds since Jan. 1, 1970 GMT = " + msec);
}
}
The code above generates the following result.