- 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
Displaymilliseconds since the epoch with Java Date and Time Conversion Character
To display milliseconds since the epoch, use the ‘Q’ Date and Time conversion specifier.
System.out.printf("
Milliseconds since epoch = %TQ", d);
The above would display milliseconds since.
1970-01-01 00:00:00 GMT
Example
import java.util.Date; public class Demo { public static void main(String[] args) { Date d = new Date(); System.out.printf("Nanoseconds = %tN
", d); System.out.printf("Seconds since epoch = %ts", d); System.out.printf("
Milliseconds since epoch = %TQ", d); } }
Output
Nanoseconds = 050000000 Seconds since epoch = 1543241478 Milliseconds since epoch = 1543241478050
Advertisements