Date and Time

Java 8 Epoch LocalDate | ofEpochDay | ofYearDay

Epoch day uses the local time-line, ignoring offset and time-zone and strictly defined to have the same meaning in all calendar systems.

  • The epoch-day, based on the Java epoch of 1970-01-01 (ISO).
  • This field is the sequential count of days where 1970-01-01 (ISO) is zero.
  • This is necessary to ensure interoperation between calendars.
import java.time.Clock;
import java.time.LocalDate;
import java.time.Month;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;

public class LocalDateTest 
{
 public static void main(String[] args) 
 {
 
 
 LocalDate epochyLocalDate = LocalDate.ofEpochDay(5);
 System.out.println("epochy day : "+epochyLocalDate);
 
 LocalDate yearOfDay = LocalDate.ofYearDay(2020, 125);
 System.out.println("epochy day count form 2020 : "+yearOfDay);
 

 
 }
}

Output:

epochy day : 1970-01-06
epochy day count form 2020 : 2020-05-04