List of utility methods to do Calendar Calculate
void | roundBack(Calendar start) Rounds a date backwards if it found to be before th start of a work day. if (!(isInWorkDay(start) && isInWorkTime(start))) { if (isBeforeWorkTime(start) || !isInWorkDay(start)) { start.add(Calendar.DATE, -1); if (start.get(Calendar.DAY_OF_WEEK) == 1) { start.add(Calendar.DATE, -2); if (start.get(Calendar.DAY_OF_WEEK) == 7) { ... |
GregorianCalendar | roundCalToNextQuarterHour(GregorianCalendar cal) Returns a calendar that has been rounded to the next quarter hour and zeros out the seconds and milliseconds. int minutes = cal.get(Calendar.MINUTE); if (minutes > 45) { cal.set(Calendar.MINUTE, 0); cal.add(Calendar.HOUR, 1); } else if (minutes > 30) { cal.set(Calendar.MINUTE, 45); } else if (minutes > 15) { cal.set(Calendar.MINUTE, 30); ... |
Date | transform(Calendar cal) transform return cal.getTime();
|
Calendar | truncate(Calendar ca) Truncate to begin of day: 0 hour 0 minute 0 second 0 millisecond truncateHour(ca);
ca.set(Calendar.HOUR_OF_DAY, 0);
return ca;
|
void | truncateHour(Calendar ca) truncate Hour ca.set(Calendar.MILLISECOND, 0); ca.set(Calendar.SECOND, 0); ca.set(Calendar.MINUTE, 0); |