Java Data Type How to - Count number of days between two dates in Java8


We would like to know how to count number of days between two dates in Java8.


import static java.time.temporal.ChronoUnit.DAYS;
/*ww  w  . ja  va  2 s .c  om*/
import java.time.LocalDate;
import java.time.Month;
import java.time.Period;
public class Main {
  public static void main(String[] argv) {
    LocalDate startEmployment = LocalDate.of(2010, Month.SEPTEMBER, 8);
    LocalDate today =;
    Period period = startEmployment.until(today);
    System.out.println("period = " + period);
    long numberOfDays = startEmployment.until(today, DAYS);
    System.out.println("numberOfDays = " + numberOfDays);

The code above generates the following result.