Here you can find the source of daysBetween(final Date date1, final Date date2)
public static int daysBetween(final Date date1, final Date date2)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.Date; public class Main { public static int daysBetween(final Date date1, final Date date2) { return (int) ((getZeroTimeDate(date1).getTime() - getZeroTimeDate(date2).getTime()) / (1000 * 60 * 60 * 24)); }//w w w . ja v a 2s.co m public static Date getZeroTimeDate(final Date date) { final Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); return calendar.getTime(); } }