The getEpochSecond() method of Instant class is used to return the number of seconds from the Java epoch of 1970-01-01T00:00:00Z. It means the difference between time in seconds of this instance and time represented by “1970-01-01T00:00:00Z” is returned by this method. The epoch second count is a simple incrementing count of seconds where the second 0 is 1970-01-01T00:00:00Z.
public long getEpochSecond()
Returns: This method returns the seconds from the epoch of 1970-01-01T00:00:00Z.
Below programs illustrate the Instant.getEpochSecond() method:
Instant: 2018-10-20T16:55:30Z Java epoch Value: 1540054530
Current Instant: 2018-11-22T08:26:19.502Z Java epoch Value: 1542875179
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.