- 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 get Epoch seconds from Instant
Create an Instant and get an Instant using milliseconds passed as parameter from the epoch of 1970-01- 01T00:00:00Z. This is done using ofEpochMilli():
Instant instant = Instant.ofEpochMilli(342627282920l);
Now, get the Epoch seconds from Instant:
instant.getEpochSecond();
Example
import java.time.Instant; public class Demo { public static void main(String[] args) { Instant instant = Instant.ofEpochMilli(342627282920l); long res = instant.getEpochSecond(); System.out.println(res); } }
Output
342627282
- Related Articles
- Java Program to get Milli seconds from Instant
- Java Program to create Instant from Epoch second and millisecond
- Java Program to minus seconds and nanoseconds from Instant
- Java Program to get the seconds since the beginning of the Java epoch
- How to get the seconds and minutes between two Instant timestamps in Java
- How can I get seconds since epoch in JavaScript?
- Java Program to create Duration from seconds
- Instant get() method in Java
- Java Program to convert Instant to LocalDateTime
- Java Program to convert java.util.Date to Instant
- Display seconds since the epoch with Java Date and Time Conversion Character
- How to get (format) date and time from mill seconds in Java?
- Java Program to get the difference between two time zones by seconds
- Why do we get instant energy from glucose?
- How to get the duration between two Instant timestamps in Java

Advertisements