Here you can find the source of dayDiff(Date start, Date end)
public static long dayDiff(Date start, Date end)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static long dayDiff(Date start, Date end) { long day = compareDate(start, end); if (day == 0) { return 0; }/* w w w . j av a 2 s . com*/ if (day > 0) { return (day - 1) / 1000 / 60 / 60 / 24 + 1; } else { return (day + 1) / 1000 / 60 / 60 / 24 - 1; } } public static long compareDate(Date start, Date end) { long temp = 0; Calendar starts = Calendar.getInstance(); Calendar ends = Calendar.getInstance(); starts.setTime(start); ends.setTime(end); temp = ends.getTime().getTime() - starts.getTime().getTime(); return temp; } }