Here you can find the source of daysBetween(Calendar early, Calendar late)
public static final int daysBetween(Calendar early, Calendar late)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.Date; public class Main { public static final int daysBetween(Calendar early, Calendar late) { return (int) (toJulian(late) - toJulian(early)); }//from w w w. j a v a2s . co m public static final int daysBetween(Date early, Date late) { Calendar c1 = Calendar.getInstance(); Calendar c2 = Calendar.getInstance(); c1.setTime(early); c2.setTime(late); return daysBetween(c1, c2); } /** * Return a Julian date based on the input parameter. This is based from * calculations found at * * <pre> * <a href="http://quasar.as.utexas.edu/BillInfo/JulianDatesG.html">Julian Day * Calculations (Gregorian Calendar)</a>, provided by Bill Jeffrys. * </pre> * * @param c * a calendar instance * @return the julian day number */ public static final float toJulian(Calendar c) { int Y = c.get(Calendar.YEAR); int M = c.get(Calendar.MONTH); int D = c.get(Calendar.DATE); int A = Y / 100; int B = A / 4; int C = 2 - A + B; float E = (int) (365.25f * (Y + 4716)); float F = (int) (30.6001f * (M + 1)); float JD = C + D + E + F - 1524.5f; return JD; } }