Here you can find the source of daysBetweenForDate(Calendar startDate, Calendar endDate)
public static long daysBetweenForDate(Calendar startDate, Calendar endDate)
//package com.java2s; //License from project: Apache License import java.util.Calendar; public class Main { public static long daysBetweenForDate(Calendar startDate, Calendar endDate) { Calendar date = (Calendar) startDate.clone(); date.set(Calendar.HOUR_OF_DAY, 0); date.set(Calendar.MINUTE, 0); date.set(Calendar.SECOND, 0); date.set(Calendar.MILLISECOND, 0); endDate.set(Calendar.HOUR_OF_DAY, 0); endDate.set(Calendar.MINUTE, 0); endDate.set(Calendar.SECOND, 0); endDate.set(Calendar.MILLISECOND, 0); long daysBetween = 0; while (date.before(endDate)) { date.add(Calendar.DAY_OF_MONTH, 1); daysBetween++;// w w w .ja va 2 s.com } return daysBetween; } }