List of utility methods to do Calendar Between
long | hoursBetween(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; |
boolean | isBetween(Calendar time, Calendar start, Calendar end) is Between return (time.compareTo(start) >= 0 && time.compareTo(end) <= 0);
|
int | numberOfDaysBetween(Calendar start, Calendar end) number Of Days Between long span = end.getTimeInMillis() - start.getTimeInMillis(); return (int) (span / numberOfMSInADay); |