- 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
Get time in milliseconds using Java Calendar
Create a Calendar object.
Calendar cal = Calendar.getInstance();
For using above Calendar class, do not forget to import the following package.
import java.util.Calendar;
Now, use the getTimeInMillis() method to get the time in milliseconds.
cal.getTimeInMillis()
The following is the final example.
Example
import java.util.Calendar; public class Demo { public static void main(String[] args) { Calendar cal = Calendar.getInstance(); System.out.println("Milliseconds =" + cal.getTimeInMillis()); } }
Output
Milliseconds =1542636999896
- Related Articles
- Java Program to get Milliseconds between two time instants
- How to get time in milliseconds using C++ on Linux?
- How to get Time in Milliseconds for the Given date and time in Java?
- Compare date time using after() method of Java Calendar
- Compare date time using before() method of Java Calendar
- How to get current time in milliseconds in Python?
- Get week of month and year using Java Calendar
- Display entire date time with milliseconds in Java
- Java Program to display computer time in milliseconds
- Java Program to display date and time in Milliseconds
- Java Program to get milliseconds between dates
- Computer elapsed time of an operation in milliseconds in Java
- How to get time in milliseconds since the Unix epoch in JavaScript?
- Set the Date and Time with Gregorian Calendar in Java
- Display Month of Year using Java Calendar

Advertisements