Here you can find the source of dayDistance(Calendar date1, Calendar date2)
public static int dayDistance(Calendar date1, Calendar date2)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; public class Main { public static int dayDistance(Calendar date1, Calendar date2) { int noDays = 0; if (date1.before(date2)) { Calendar temp = Calendar.getInstance(); temp.setTimeInMillis(date1.getTimeInMillis()); while (temp.before(date2)) { temp.add(Calendar.DATE, 1); noDays++;/*from w ww. jav a 2 s. com*/ } } else if (date1.after(date2)) { Calendar temp = Calendar.getInstance(); temp.setTimeInMillis(date2.getTimeInMillis()); while (temp.before(date1)) { temp.add(Calendar.DATE, 1); noDays++; } } return noDays; } }