Here you can find the source of daysBetweenxX(Calendar start, Calendar end)
public static long daysBetweenxX(Calendar start, Calendar end)
//package com.java2s; /******************************************************************************* * Copyright (c) Emil Crumhorn - Hexapixel.com - emil.crumhorn@gmail.com * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://from ww w . ja v a 2 s. com * emil.crumhorn@gmail.com - initial API and implementation *******************************************************************************/ import java.util.Calendar; import java.util.GregorianCalendar; public class Main { private static final long MILLISECONDS_IN_DAY = 24 * 60 * 60 * 1000; public static long daysBetweenxX(Calendar start, Calendar end) { //reset all hours mins and secs to zero on start date Calendar startCal = GregorianCalendar.getInstance(); startCal.setTime(start.getTime()); startCal.set(Calendar.HOUR_OF_DAY, 0); startCal.set(Calendar.MINUTE, 0); startCal.set(Calendar.SECOND, 0); long startTime = startCal.getTimeInMillis(); //reset all hours mins and secs to zero on end date Calendar endCal = GregorianCalendar.getInstance(); endCal.setTime(end.getTime()); endCal.set(Calendar.HOUR_OF_DAY, 0); endCal.set(Calendar.MINUTE, 0); endCal.set(Calendar.SECOND, 0); long endTime = endCal.getTimeInMillis(); return (endTime - startTime) / MILLISECONDS_IN_DAY; } }