Java LocalDate create from Epoch Day

Description

Java LocalDate create from Epoch Day

import java.time.LocalDate;
import java.time.Month;

public class Main {
  public static void main(String[] args) {
    // Get the current local date
    LocalDate ldt1 = LocalDate.now();

    // Create a local date May 10, 2020
    LocalDate ldt2 = LocalDate.of(2020, Month.MAY, 10);

    // Create a local date, which is 10 days after the epoch date 1970-01-01
    LocalDate ldt3 = LocalDate.ofEpochDay(10); // 1970-01-11
    System.out.println(ldt1);/*from w w  w  .j  ava2  s . c  o m*/
    System.out.println(ldt2);
    System.out.println(ldt3);
  }
}



PreviousNext

Related