Here you can find the source of getDistDates(Date startDate, Date endDate)
public static long getDistDates(Date startDate, Date endDate)
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static long getDistDates(Date startDate, Date endDate) { long totalDate = 0; Calendar calendar = Calendar.getInstance(); calendar.setTime(startDate);/*from ww w . j av a2s. c o m*/ long timestart = calendar.getTimeInMillis(); calendar.setTime(endDate); long timeend = calendar.getTimeInMillis(); totalDate = Math.abs((timeend - timestart)) / (1000 * 60 * 60 * 24); return totalDate; } }