Java tutorial
//package com.java2s; import java.util.Calendar; public class Main { public static int daysBetween(java.sql.Date date1, java.sql.Date date2) { Calendar cal = Calendar.getInstance(); cal.setTime(date1); long time1 = cal.getTimeInMillis(); cal.setTime(date2); long time2 = cal.getTimeInMillis(); long between_days = (time2 - time1) / (1000 * 3600 * 24); return Integer.parseInt(String.valueOf(between_days)); } }