List of utility methods to do Day of Week
boolean | isMatchWeek(Date date, int week) is Match Week return getWeekOfDate(date) == week;
|
boolean | isOnWeekend(Date date) Uses the Calendar to see of the day of week is equal to saturday or sunday. Calendar cal = Calendar.getInstance();
cal.setTime(date);
return ((cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY)
|| (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY));
|
boolean | isSameWeekDates(Date date1, Date date2) is Same Week Dates long diff = getMonday(date1).getTime() - getMonday(date2).getTime(); if (Math.abs(diff) < 1000 * 60 * 60 * 24) { return true; } else { return false; |
boolean | isWeekday(Date startDate) decides if a day is Mon through Fri GregorianCalendar cal = new GregorianCalendar(); cal.setTime(startDate); if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY) return false; return true; |
boolean | isWeekDay(final Date date) Figure out whether a Date is a week day. if (null == date) { return false; Calendar cal = Calendar.getInstance(); cal.setTime(date); if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) { return false; ... |
boolean | isWeekEnd(Date date) is Week End Calendar cal = Calendar.getInstance(); cal.setTime(date); if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY) return true; else return false; |
boolean | isWeekend(Date date) is Weekend Calendar c = Calendar.getInstance(); if (date != null) c.setTime(date); int weekDay = c.get(7); return ((weekDay == 1) || (weekDay == 7)); |
boolean | isWeekend(Date date) is Weekend boolean result = false; int day = getDayOfWeek(date); result = false; result = result || day == Calendar.SATURDAY; result = result || day == Calendar.SUNDAY; return result; |
boolean | isWeekend(Date date) Tests the input date to check if the date falls on a weekend. if (isSaturday(date) || isSunday(date)) return true; else return false; |
boolean | isWeekend(Date date) is Weekend return isWeekend(calendar(date));
|