Here you can find the source of getDayDiff(Date firstDate, Date secondDate)
public static int getDayDiff(Date firstDate, Date secondDate)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { /**//from w w w. j ava 2 s .c o m * Returns the difference of two dates in days (fristDay - secondDay). * <p/> * The argument are thereby not assumed to be in any order: the names are just used in order to the ease the * understanding) */ public static int getDayDiff(Date firstDate, Date secondDate) { long fristDay = (int) (firstDate.getTime() / (86400. * 1000.)); long secondDay = (int) (secondDate.getTime() / (86400. * 1000.)); return (int) (fristDay - secondDay); } }