Here you can find the source of getDaysBetweenDate(Date begin, Date end)
public static int getDaysBetweenDate(Date begin, Date end)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static int getDaysBetweenDate(Date begin, Date end) { int bDay = getDateField(begin, Calendar.DAY_OF_YEAR); int eDay = getDateField(end, Calendar.DAY_OF_YEAR); return eDay - bDay; }/* ww w .ja va 2 s.c o m*/ private static int getDateField(Date date, int field) { Calendar c = getCalendar(); c.setTime(date); return c.get(field); } private static Calendar getCalendar() { return Calendar.getInstance(); } public static int get(int field, Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); return c.get(field); } }