public static long daysBetween(Date startDate,Date endDate){
  Calendar sDate=getDatePart(startDate);
  Calendar eDate=getDatePart(endDate);
  long daysBetween=0;
  while (sDate.before(eDate)) {
    sDate.add(Calendar.DAY_OF_MONTH,1);
    daysBetween++;
  }
  return daysBetween;
}

public static long daysBetween ( Date startDate , Date endDate ) { Calendar sDate = getDatePart ( startDate ) ; Calendar eDate = getDatePart ( endDate ) ; long daysBetween = 0 ; while ( sDate . before ( eDate ) ) { sDate . add ( Calendar . DAY_OF_MONTH , 1 ) ; daysBetween ++ ; } return daysBetween ; }
this method also assumes enddate > = startdate
