 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- 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
Advertisements
 