Java LocalDate get days between two LocalDate values

Description

Java LocalDate get days 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,  21); 
     long  days  = ChronoUnit.DAYS.between(ld1, ld2);
     //from   w w  w.  jav a  2 s .  c  o m
     System.out.println(days);

  }
}



PreviousNext

Related