Java Data Type How to - Count days between two dates


We would like to know how to count days between two dates.


//w  ww. j av a 2 s . c o  m
import java.time.LocalDate;
import java.time.Month;
import java.time.Period;

public class Main {
  public static void main(String[] argv) {
    LocalDate today =;
    LocalDate longestDay = today.with(Month.JUNE).withDayOfMonth(21);
    int p = Period.between(today, longestDay).getDays();

The code above generates the following result.