List of utility methods to do Calendar Day
boolean | isAfterDay(Calendar cal1, Calendar cal2) Checks if the first calendar date is after the second calendar date ignoring time. if (cal1 == null || cal2 == null) { throw new IllegalArgumentException("The dates must not be null"); if (cal1.get(Calendar.ERA) < cal2.get(Calendar.ERA)) return false; if (cal1.get(Calendar.ERA) > cal2.get(Calendar.ERA)) return true; if (cal1.get(Calendar.YEAR) < cal2.get(Calendar.YEAR)) ... |
boolean | isAllDayEvent(Calendar dtStart, Calendar dtEnd) is All Day Event boolean startAtNullOClock = false; boolean endAtNullOClock = false; boolean allDayEvent = false; startAtNullOClock = ((dtStart.get(java.util.Calendar.MILLISECOND) == 0) && (dtStart.get(java.util.Calendar.SECOND) == 0) && (dtStart.get(java.util.Calendar.MINUTE) == 0) && (dtStart.get(java.util.Calendar.HOUR_OF_DAY) == 0)); endAtNullOClock = ((dtEnd.get(java.util.Calendar.MILLISECOND) == 0) && (dtEnd.get(java.util.Calendar.SECOND) == 0) && (dtEnd.get(java.util.Calendar.MINUTE) == 0) ... |
boolean | isBusinessDay(Calendar cal) Is Date A Business Day? if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) { return false; if (cal.get(Calendar.MONTH) == Calendar.JANUARY && cal.get(Calendar.DAY_OF_MONTH) == 1) { return false; if (cal.get(Calendar.MONTH) == Calendar.DECEMBER && cal.get(Calendar.DAY_OF_MONTH) == 25) { ... |
boolean | isDayAfter(Calendar calendar, Calendar baseCalendar) is Day After if (calendar.get(Calendar.YEAR) > baseCalendar.get(Calendar.YEAR)) { return true; } else if (calendar.get(Calendar.YEAR) < baseCalendar.get(Calendar.YEAR)) { return false; if (calendar.get(Calendar.MONTH) > baseCalendar.get(Calendar.MONTH)) { return true; } else if (calendar.get(Calendar.MONTH) < baseCalendar.get(Calendar.MONTH)) { ... |
boolean | isDSTChangeDay(Calendar cal) Determine whether a specific date is on DST change day return hoursInDay(cal) != 24;
|
boolean | isEndOfDay(Calendar calendar) Returns a boolean indicating if the given calendar represents the end of a day (in the calendar's time zone). Calendar temp = (Calendar) calendar.clone();
temp.add(Calendar.MILLISECOND, 1);
return temp.get(Calendar.DATE) != calendar.get(Calendar.DATE);
|
boolean | isHolyday(Calendar c) is Holyday int month = c.get(Calendar.MONTH); int dayOfMonth = c.get(Calendar.DAY_OF_MONTH); if (month == Calendar.JANUARY) { if (dayOfMonth == 1) return true; if (dayOfMonth == 6) return true; if (month == Calendar.APRIL && dayOfMonth == 25) return true; if (month == Calendar.MAY && dayOfMonth == 1) return true; if (month == Calendar.JUNE && dayOfMonth == 2) return true; if (month == Calendar.AUGUST && dayOfMonth == 15) return true; if (month == Calendar.NOVEMBER && dayOfMonth == 1) return true; if (month == Calendar.DECEMBER) { if (dayOfMonth == 8) return true; if (dayOfMonth == 25) return true; if (dayOfMonth == 26) return true; if (month == easterMonth && dayOfMonth == easterDay) return true; if (month == mondayEasterMonth && dayOfMonth == mondayEasterDay) return true; return false; |
boolean | isRestDay(Calendar cal) is Rest Day int weekDay = cal.get(Calendar.DAY_OF_WEEK); return weekDay == Calendar.SATURDAY || weekDay == Calendar.SUNDAY; |
boolean | isSameDay(Calendar c1, Calendar c2) is Same Day return c1.get(Calendar.YEAR) == c2.get(Calendar.YEAR) && c1.get(Calendar.MONTH) == c2.get(Calendar.MONTH)
&& c1.get(Calendar.DAY_OF_MONTH) == c2.get(Calendar.DAY_OF_MONTH);
|
boolean | isSameDay(Calendar cal1, Calendar cal2) is Same Day if (cal1 == null || cal2 == null) { throw new IllegalArgumentException("The date must not be null"); return (cal1.get(Calendar.ERA) == cal2.get(Calendar.ERA) && cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) && cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR)); |