Java LocalDate get days elapsed between two LocalDate values

Description

Java LocalDate get days elapsed between two LocalDate values

import java.time.LocalDate;
import java.time.Month;
import java.time.temporal.ChronoUnit;

public class Main {
  public static void main(String[] args) {
     LocalDate ld1 = LocalDate.of(2020, Month.JANUARY, 7);
     LocalDate ld2 = LocalDate.of(2020, Month.MAY, 18);
     //from  w  w w  .  jav a2s  .  com
     long days = ld1.until(ld2, ChronoUnit.DAYS);
     System.out.println(days);

  }
}



PreviousNext

Related