code: private int getDaysInRange(Date startDate, Date endDate)
     {
        int result;
        Calendar cal = DateHelper.popCalendar(endDate);
        int endDateYear = cal.get(Calendar.YEAR);
        int endDateDayOfYear = cal.get(Calendar.DAY_OF_YEAR);
  
        cal.setTime(startDate);
  
        if (endDateYear == cal.get(Calendar.YEAR))
        {
           result = (endDateDayOfYear - cal.get(Calendar.DAY_OF_YEAR)) + 1;
        }
        else
        {
           result = 0;
           do
           {
              result += (cal.getActualMaximum(Calendar.DAY_OF_YEAR) - cal.get(Calendar.DAY_OF_YEAR)) + 1;
              cal.roll(Calendar.YEAR, 1);
              cal.set(Calendar.DAY_OF_YEAR, 1);
           }
           while (cal.get(Calendar.YEAR) < endDateYear);
           result += endDateDayOfYear;
        }
        DateHelper.pushCalendar(cal);
        
        return result;
     }
docs: This method calculates the absolute number of days between two dates.
  Note that where two date objects are provided that fall on the same
  day, this method will return one not zero. Note also that this method
  assumes that the dates are passed in the correct order, i.e.
  startDate < endDate.
  
  @param startDate Start date
  @param endDate End date
  @return number of days in the date range