List of utility methods to do Weekend
String | endOfWeek(Date date, String format) end Of Week SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(endOfWeek(date)); |
Integer | getCalendarWeekOfDate(Date date) get Calendar Week Of Date Calendar cal = Calendar.getInstance(); cal.setTime(date); return new Integer(cal.get(Calendar.WEEK_OF_YEAR)); |
String | getCurWeekEnd(String strDate) get Cur Week End SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); dateFormat.parse(strDate, new ParsePosition(0)); Calendar calendar = dateFormat.getCalendar(); int day = calendar.get(Calendar.DAY_OF_WEEK); calendar.add(Calendar.DATE, 7 - day); return dateFormat.format(calendar.getTime()); |
List | getWeekRange(String strBeginDate, String strEndDate, String pattern) get Week Range List<String> ret = new ArrayList<String>(); Date beginDate = parseDate(strBeginDate); Date endDate = parseDate(strEndDate); String beginFormat = formatDate(beginDate, pattern); String endFormat = formatDate(endDate, pattern); ret.add(beginFormat); while (!beginFormat.equals(endFormat)) { beginDate = addWeek(beginDate, 1); ... |
boolean | isEndOfWeek() is End Of Week return getWeekNumByDate(getCurrentDate_String()) == 0;
|
boolean | isWeekend(Calendar calendar) Is date a weekend day? int dayInWeek = calendar.get(Calendar.DAY_OF_WEEK); return dayInWeek == Calendar.SATURDAY || dayInWeek == Calendar.SUNDAY; |
boolean | isWeekend(Calendar dateCal) is Weekend return (dateCal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY
|| dateCal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY);
|
boolean | isWeekend(Date date) Function: SUNDAY or SATURDAY return true Calendar calendar = Calendar.getInstance(); calendar.setTime(date); int weekday = calendar.get(Calendar.DAY_OF_WEEK); if (weekday == Calendar.SUNDAY || weekday == Calendar.SATURDAY) return true; return false; |
boolean | isWeekend(Date date) Check if the date parameter occurs during a weekend. if (date != null) { Calendar calendar = Calendar.getInstance(); calendar.setFirstDayOfWeek(Calendar.MONDAY); calendar.setTime(date); int dayOfTheWeek = calendar.get(Calendar.DAY_OF_WEEK); return dayOfTheWeek == Calendar.SATURDAY || dayOfTheWeek == Calendar.SUNDAY; } else { return false; ... |
boolean | isWeekEnd(Date datum) is Week End Calendar cal = new GregorianCalendar(); cal.setTime(datum); int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK); return dayOfWeek == Calendar.SATURDAY || dayOfWeek == Calendar.SUNDAY; |