Here you can find the source of daysBetween(LocalDate date1, LocalDate date2)
public static int daysBetween(LocalDate date1, LocalDate date2)
//package com.java2s; //License from project: Open Source License import java.time.*; import java.util.Date; public class Main { public static final ZoneId chinaZone = ZoneId.systemDefault(); public static int daysBetween(LocalDate date1, LocalDate date2) { Period period = Period.between(date1, date2); return period.getDays(); }/*from ww w. java 2s . c o m*/ public static int daysBetween(Date date1, Date date2) { Instant instantDate1 = date1.toInstant(); Instant instantDate2 = date2.toInstant(); LocalDate localDate1 = instantDate1.atZone(chinaZone).toLocalDate(); LocalDate localDate2 = instantDate2.atZone(chinaZone).toLocalDate(); instantDate1.atZone(chinaZone); Period period = Period.between(localDate1, localDate2); return period.getDays(); } }