- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Program to display date and time in Milliseconds
Firstly, to display date and time, import the following package.
import java.util.Date;
Display the current date using Date class.
Date currentDate = new Date();
Let us now get milliseconds since Jan. 1, 1970 GMT
long res = currentDate.getTime();
The following is an example.
Example
import java.util.Date; public class Example { public static void main(String args[]) { Date currentDate = new Date(); System.out.println("Current date = "+currentDate); // getting milliseconds since Jan. 1, 1970 GMT long res = currentDate.getTime(); System.out.println("Milliseconds = " + res); } }
Output
Current date = Mon Nov 19 05:32:19 UTC 2018 Milliseconds = 1542605539301
- Related Articles
- Display entire date time with milliseconds in Java
- Java Program to display computer time in milliseconds
- Java Program to Display current Date and Time
- Java Program to display date and time information in lowercase
- Java Program to display date and time information in uppercase
- How to get Time in Milliseconds for the Given date and time in Java?
- Java Program to convert Date into milliseconds
- Program to convert Milliseconds to Date Format in Java
- Golang program to display current date and time
- Java Program to get Milliseconds between two time instants
- Java Program to parse date and time
- Display complete date and time information using Formatter in Java
- Display nanoseconds with Java Date and Time Conversion Character
- Java Program to display Current Time in another Time Zone
- How to display date and time picker in ReactNative?

Advertisements