Here you can find the source of getDayCount(java.util.Date _startDate, java.util.Date _endDate)
public static int getDayCount(java.util.Date _startDate, java.util.Date _endDate)
//package com.java2s; import java.util.Calendar; public class Main { public static int getDayCount(java.util.Date _startDate, java.util.Date _endDate) { Calendar calendar = Calendar.getInstance(); calendar.setTime(_startDate);// w w w .ja v a 2 s .c om int startDay = calendar.get(Calendar.DAY_OF_YEAR); int startYear = calendar.get(Calendar.YEAR); calendar.clear(); calendar.setTime(_endDate); int endDay = calendar.get(Calendar.DAY_OF_YEAR); int endYear = calendar.get(Calendar.YEAR); calendar.clear(); return (endYear - startYear) * 365 + (endDay - startDay); } }