Here you can find the source of daysBetweenDate(Integer startDate, Integer endDate)
public static Integer daysBetweenDate(Integer startDate, Integer endDate)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static Integer daysBetweenDate(Integer startDate, Integer endDate) { if (startDate == null || endDate == null) { return null; }/*from ww w. j av a2 s . c o m*/ Calendar c1 = newCalendar(startDate); Calendar c2 = newCalendar(endDate); Long lg = (c2.getTimeInMillis() - c1.getTimeInMillis()) / 1000 / 60 / 60 / 24; return lg.intValue(); } public static Integer daysBetweenDate(Date startDate, Date endDate) { if (startDate == null || endDate == null) { return null; } Long interval = endDate.getTime() - startDate.getTime(); interval = interval / (24 * 60 * 60 * 1000); return interval.intValue(); } public static Calendar newCalendar(int year, int month, int day) { Calendar ret = Calendar.getInstance(); if (year < 100) { year = 2000 + year; } ret.set(year, month - 1, day); return ret; } public static Calendar newCalendar(int date) { int year = date / 10000; int month = (date % 10000) / 100; int day = date % 100; Calendar ret = Calendar.getInstance(); ret.set(year, month - 1, day); return ret; } }