Here you can find the source of daysBetween(final Calendar startDate, final Calendar endDate)
public static long daysBetween(final Calendar startDate, final Calendar endDate)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static long daysBetween(final Calendar startDate, final Calendar endDate) { long days = 0; while (endDate.after(startDate)) { endDate.add(Calendar.DATE, -1); ++days;/*from w w w . j a v a 2 s.com*/ } return days; } public static long daysBetween(final Date startDate, final Date endDate) { Calendar start = Calendar.getInstance(); Calendar end = Calendar.getInstance(); start.setTime(startDate); end.setTime(endDate); return daysBetween(start, end); } }