Here you can find the source of diffDay(Date date1, Date date2)
public static int diffDay(Date date1, Date date2)
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static int diffDay(Date date1, Date date2) { Calendar aCalendar = Calendar.getInstance(); aCalendar.setTime(date1);/*from ww w . j a v a2 s . co m*/ int day1 = aCalendar.get(Calendar.DAY_OF_YEAR); Calendar bCalendar = Calendar.getInstance(); bCalendar.setTime(date2); int day2 = bCalendar.get(Calendar.DAY_OF_YEAR); return day2 - day1; } }