List of utility methods to do Calendar Between
long | daysBetweenForDate(Calendar startDate, Calendar endDate) days Between For Date Calendar date = (Calendar) startDate.clone(); date.set(Calendar.HOUR_OF_DAY, 0); date.set(Calendar.MINUTE, 0); date.set(Calendar.SECOND, 0); date.set(Calendar.MILLISECOND, 0); endDate.set(Calendar.HOUR_OF_DAY, 0); endDate.set(Calendar.MINUTE, 0); endDate.set(Calendar.SECOND, 0); ... |
long | daysBetweenxX(Calendar start, Calendar end) days Betweenx X Calendar startCal = GregorianCalendar.getInstance();
startCal.setTime(start.getTime());
startCal.set(Calendar.HOUR_OF_DAY, 0);
startCal.set(Calendar.MINUTE, 0);
startCal.set(Calendar.SECOND, 0);
long startTime = startCal.getTimeInMillis();
Calendar endCal = GregorianCalendar.getInstance();
endCal.setTime(end.getTime());
...
|
int | getDaysBetween(Calendar d1, Calendar d2) Calculates the number of days between two calendar days in a manner which is independent of the Calendar type used. if (d1.after(d2)) { Calendar swap = d1; d1 = d2; d2 = swap; int days = d2.get(Calendar.DAY_OF_YEAR) - d1.get(Calendar.DAY_OF_YEAR); int y2 = d2.get(Calendar.YEAR); if (d1.get(Calendar.YEAR) != y2) { ... |
int | getDaysBetween(Calendar d1, Calendar d2) get Days Between int days = 0; int years = d1.get(Calendar.YEAR) - d2.get(Calendar.YEAR); if (years == 0) { days = d2.get(Calendar.DAY_OF_YEAR) - d1.get(Calendar.DAY_OF_YEAR); return days; } else if (years > 0) { for (int i = 0; i < years; i++) { d2.add(Calendar.YEAR, 1); ... |
int | getDaysBetween(Calendar firstDate, Calendar lastDate) Return the number of whole days between two dates long diffMillis = lastDate.getTimeInMillis() - firstDate.getTimeInMillis(); return (int) Math.floorDiv(diffMillis, MILLIS_PER_DAY); |
int | getDaysBetween(Calendar start, Calendar end) get Days Between if (start.after(end)) { Calendar swap = start; start = end; end = swap; int days = end.get(Calendar.DAY_OF_YEAR) - start.get(Calendar.DAY_OF_YEAR); int y2 = end.get(Calendar.YEAR); if (start.get(Calendar.YEAR) != y2) { ... |
int | getDaysBetween(Calendar startDate, Calendar endDate) get Days Between if (startDate.after(endDate)) { java.util.Calendar swap = startDate; startDate = endDate; endDate = swap; int days = endDate.get(java.util.Calendar.DAY_OF_YEAR) - startDate.get(java.util.Calendar.DAY_OF_YEAR); int y2 = endDate.get(java.util.Calendar.YEAR); if (startDate.get(java.util.Calendar.YEAR) != y2) { ... |
double | getDaysBetween(final Calendar start, final Calendar end) get Days Between return getDaysBetween(start.getTimeInMillis(), end.getTimeInMillis());
|
void | getFmtCalendar(Calendar c, long betweenTimeout, StringBuilder sb) get Fmt Calendar sb.append("\tspan:"); sb.append(c.get(Calendar.MINUTE)); sb.append("m:"); sb.append(c.get(Calendar.SECOND)); sb.append("s:"); sb.append(c.get(Calendar.MILLISECOND)); sb.append("ms"); if (betweenTimeout > 0) { ... |
int | hoursBetween(Calendar start, Calendar end, boolean assumeSameDate) hours Between return minutesBetween(start.getTime(), end.getTime(), assumeSameDate, false) / 60;
|