Java LocalDate get days between two LocalDate values using until method

Description

Java LocalDate get days between two LocalDate values using until method

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);
    long days = ld1.until(ld2, ChronoUnit.DAYS);
    System.out.println(days);/*from  ww w . ja  va 2  s  . c om*/
  }
}



PreviousNext

Related