Java tutorial
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { /** * Return the difference between 2 dates (dayTwo - dayOne) in days * @param dayTwo The first day to compare against * @param dayOne The second day to compare against * @return an int of the difference between the 2 days */ public static int diffDays(Date dayTwo, Date dayOne) { Calendar calOne = Calendar.getInstance(); calOne.setTime(dayOne); long msOne = calOne.getTimeInMillis(); Calendar calTwo = Calendar.getInstance(); calTwo.setTime(dayTwo); long msTwo = calTwo.getTimeInMillis(); return (int) ((msTwo - msOne) / (1000L * 60L * 60L * 24L)); } }