Here you can find the source of getDiffDays(Date date1, Date date2)
public static int getDiffDays(Date date1, Date date2)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.Date; public class Main { private static long MILLIS_ONE_DATE = 1000 * 3600 * 24; public static int getDiffDays(Date date1, Date date2) { Calendar c = Calendar.getInstance(); c.setTime(date1);//from w w w . ja va 2 s. c om long time1 = c.getTimeInMillis(); c.setTime(date2); long time2 = c.getTimeInMillis(); long between_days = (time2 - time1) / MILLIS_ONE_DATE; return Integer.parseInt(String.valueOf(between_days)); } }