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