Java tutorial
//package com.java2s; import java.util.Date; public class Main { public static int compareDateToDays(Date firstDate, Date lastDate) { if (firstDate == null || lastDate == null) { System.out.print("NULL"); } long time1 = firstDate.getTime(); long time2 = lastDate.getTime(); long tmpCal = time2 - time1; long mm = 24 * 60 * 60 * 1000; int days = (int) (tmpCal / mm); return Math.abs(days); } }