Here you can find the source of getDaysBetween(Calendar start, Calendar end)
public static int getDaysBetween(Calendar start, Calendar end)
//package com.java2s; import java.util.Calendar; public class Main { public static int getDaysBetween(Calendar start, Calendar end) { if (start.after(end)) { Calendar swap = start; start = end;/*from w ww .j a v a2s . c om*/ end = swap; } int days = end.get(Calendar.DAY_OF_YEAR) - start.get(Calendar.DAY_OF_YEAR); int y2 = end.get(Calendar.YEAR); if (start.get(Calendar.YEAR) != y2) { start = (Calendar) start.clone(); do { days += start.getActualMaximum(Calendar.DAY_OF_YEAR); start.add(Calendar.YEAR, 1); } while (start.get(Calendar.YEAR) != y2); } return days; } }