Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Java Program to convert Date into milliseconds
Import the following package to work with Date class.
import java.util.Date;
No create a Date object.
Date d = new Date();
Let us convert the current date to milliseconds.
d.getTime()
The following is an example.
Example
import java.util.Date;
public class Demo {
public static void main(String[] args) {
Date d = new Date();
System.out.println("Date = " + d);
System.out.println("Milliseconds since January 1, 1970, 00:00:00 GMT = " + d.getTime());
}
}
Output
Date = Mon Nov 19 06:30:11 UTC 2018 Milliseconds since January 1, 1970, 00:00:00 GMT = 1542609011369
Advertisements
