List of utility methods to do Calendar Week
String | getWeekDay(Calendar cal) get Week Day int Day_No = cal.get(Calendar.DAY_OF_WEEK); String WeekDay = "Sunday"; switch (Day_No) { case Calendar.SUNDAY: { WeekDay = "Sun"; break; case Calendar.MONDAY: { ... |
int | getWeekdayPosition(Calendar jCalendar) get Weekday Position int weekOfMonth = jCalendar.get(Calendar.WEEK_OF_MONTH); Calendar firstDayJCalendar = (Calendar) jCalendar.clone(); firstDayJCalendar.set(Calendar.DAY_OF_MONTH, 1); if (firstDayJCalendar.get(Calendar.DAY_OF_WEEK) > jCalendar.get(Calendar.DAY_OF_WEEK)) { return weekOfMonth - 1; return weekOfMonth; |
Calendar | getWeekEnd(boolean startSunday, Calendar date) Returns a date corresponding to the last day of the week. if (date == null) { date = new GregorianCalendar(); Calendar end = getWeekStart(startSunday, date); end.add(Calendar.DAY_OF_MONTH, 6); end.setTime(getDayEnd(end.getTime())); return end; |
int | getWeekOfCurrentDayWithoutStartShift(Calendar cal) get Week Of Current Day Without Start Shift int eventStartDay = cal.get(Calendar.DAY_OF_MONTH); int eventWeekOfMonth = cal.get(Calendar.WEEK_OF_MONTH); int eventRealWeekOfMonth = getRealWeekOfDay(eventStartDay); return adjustWeekOfMonth(eventWeekOfMonth, eventRealWeekOfMonth); |
Calendar | getWeekStart(boolean startSunday, Calendar date) Returns a date corresponding to the first day of the week. Calendar start = new GregorianCalendar(); if (date != null) { start.setTime(date.getTime()); int current_dow = start.get(Calendar.DAY_OF_WEEK); start.add(Calendar.DAY_OF_MONTH, -current_dow); start.add(Calendar.DAY_OF_MONTH, startSunday ? Calendar.SUNDAY : Calendar.MONDAY); start.setTime(getDayStart(start.getTime())); ... |
boolean | isThisWeek(Calendar time) is This Week if (time != null) { Calendar weekStart = getCalendar(); snapStartOfWorkWeek(weekStart); Calendar weekEnd = getCalendar(); snapEndOfWeek(weekEnd); return (time.compareTo(weekStart) >= 0 && time.compareTo(weekEnd) <= 0); return false; ... |
boolean | isWeekday(Calendar cal) is Weekday int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK); return !(dayOfWeek < Calendar.MONDAY || dayOfWeek > Calendar.FRIDAY); |
boolean | isWeekEnd(Calendar c) is Week End int day = c.get(Calendar.DAY_OF_WEEK); if (day == Calendar.SUNDAY || day == Calendar.SATURDAY) { return true; return false; |
boolean | isWeekend(Calendar cal) Gets the weekend attribute of the DateUtils class return (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY
|| cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY);
|
boolean | isWeekend(GregorianCalendar date) is Weekend return isSaturday(date) || isSunday(date);
|