Java Utililty Methods Calendar Between

List of utility methods to do Calendar Between

Description

The list of methods to do Calendar Between are organized into topic(s).

Method

longhoursBetween(Calendar startDate, Calendar endDate)
hours Between
Calendar date = (Calendar) startDate.clone();
long hoursBetween = -1;
while (date.before(endDate) || date.equals(endDate)) {
    date.add(Calendar.HOUR, 1);
    hoursBetween++;
return hoursBetween;
booleanisBetween(Calendar time, Calendar start, Calendar end)
is Between
return (time.compareTo(start) >= 0 && time.compareTo(end) <= 0);
intnumberOfDaysBetween(Calendar start, Calendar end)
number Of Days Between
long span = end.getTimeInMillis() - start.getTimeInMillis();
return (int) (span / numberOfMSInADay);