Here you can find the source of getDiffDays(Date from, Date to)
public static long getDiffDays(Date from, Date to)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static long getDiffDays(String startStr, String endStr) { GregorianCalendar start = getGregorianCalendar(startStr); GregorianCalendar end = getGregorianCalendar(endStr); return (start.getTime().getTime() - end.getTime().getTime()) / 86400000; }/*from w w w . j a v a 2 s .c o m*/ public static long getDiffDays(Date from, Date to) { return (to.getTime() - from.getTime()) / 86400000; } public static GregorianCalendar getGregorianCalendar(String yyyymmdd) { int yyyy = Integer.parseInt(yyyymmdd.substring(0, 4)); int mm = Integer.parseInt(yyyymmdd.substring(4, 6)); int dd = Integer.parseInt(yyyymmdd.substring(6, 8)); GregorianCalendar calendar = new GregorianCalendar(yyyy, mm - 1, dd, 0, 0, 0); return calendar; } }