What is Epoch time in Java?




Asked on August 28, 2019
What is Epoch time in Java?



Replied on August 29, 2019
An epoch is an instant in time used as an origin of particular calendar era. Epoch is a reference point from which a time is measured.

In java.time package, we have classes to handle epoch.

1. ChronoLocalDateTime. toEpochSecond()
Converts this date-time to the number of seconds from the epoch of 1970-01-01T00:00:00Z.

2. LocalDateTime.ofEpochSecond() : 
Obtains an instance of LocalDateTime using seconds from the epoch of 1970-01-01T00:00:00Z.

3. LocalDate.ofEpochDay(): 
This returns a LocalDate with the specified epoch-day. The EPOCH_DAY is a simple incrementing count of days where day 0 is 1970-01-01.

4. LocalDate.toEpochDay():
The Epoch Day count is a simple incrementing count of days where day 0 is 1970-01-01 (ISO).





Write Answer










©2024 concretepage.com | Privacy Policy | Contact Us