Here you can find the source of dayDuration(LocalDateTime startDateTime, LocalDateTime endDateTime)
public static long dayDuration(LocalDateTime startDateTime, LocalDateTime endDateTime)
//package com.java2s; //License from project: Apache License import java.time.*; import java.time.temporal.ChronoUnit; import java.util.Date; public class Main { public static long dayDuration(LocalDateTime startDateTime, LocalDateTime endDateTime) { return duration(startDateTime, endDateTime).toDays(); }/*from w ww. java 2s .c o m*/ public static long dayDuration(LocalDate startDate, LocalDate endDate) { return ChronoUnit.DAYS.between(startDate, endDate); } public static long dayDuration(Date startDate, Date endDate) { long time1 = startDate.getTime(); long time2 = endDate.getTime(); long diff; if (time1 < time2) { diff = time2 - time1; } else { diff = time1 - time2; } return diff / (1000 * 60 * 60 * 24); } public static Duration duration(LocalDateTime startDateTime, LocalDateTime endDateTime) { return Duration.between(startDateTime, endDateTime); } }