Here you can find the source of betweenTwoDates(Date date1, Date date2)
public static int betweenTwoDates(Date date1, Date date2)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static int betweenTwoDates(Date date1, Date date2) { return (int) ((getMillis(date1) - getMillis(date2)) / (24 * 3600 * 1000)); }/* w w w . j a v a2 s . com*/ public static long getMillis(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); return c.getTimeInMillis(); } }