- 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
Display seconds since the epoch with Java Date and Time Conversion Character
To display seconds since the epoch, use the ‘s’ Date and Time conversion specifier.
System.out.printf("Seconds since epoch = %ts", d);
The above would display seconds 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); } }
Output
Nanoseconds = 364000000 Seconds since epoch = 1543241402
- Related Articles
- Displaymilliseconds since the epoch with Java Date and Time Conversion Character
- Display nanoseconds with Java Date and Time Conversion Character
- How can I get time and date since epoch in JavaScript?
- Java Program to get the seconds since the beginning of the Java epoch
- How can I get seconds since epoch in JavaScript?
- Display entire date time with milliseconds in Java
- How to get time in milliseconds since the Unix epoch in JavaScript?
- Java Program to Display current Date and Time
- Display the Asian and American Date Time with Date Object in JavaScript
- Java Program to display date and time in Milliseconds
- Java Program to get Epoch seconds from Instant
- How to Convert Epoch Time to Date in SQL?
- Display complete date and time information using Formatter in Java
- Java Program to display date and time information in lowercase
- Java Program to display date and time information in uppercase

Advertisements