Here you can find the source of getDayBetween(Date startDate, Date endDate)
public static final Integer getDayBetween(Date startDate, Date endDate)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static final Integer getDayBetween(Date startDate, Date endDate) { Calendar start = Calendar.getInstance(); start.setTime(startDate);/*from w w w .ja v a 2 s . c o m*/ start.set(Calendar.HOUR_OF_DAY, 0); start.set(Calendar.MINUTE, 0); start.set(Calendar.SECOND, 0); start.set(Calendar.MILLISECOND, 0); Calendar end = Calendar.getInstance(); end.setTime(endDate); end.set(Calendar.HOUR_OF_DAY, 0); end.set(Calendar.MINUTE, 0); end.set(Calendar.SECOND, 0); end.set(Calendar.MILLISECOND, 0); long n = end.getTimeInMillis() - start.getTimeInMillis(); return (int) (n / (60 * 60 * 24 * 1000l)); } }