List of utility methods to do Calendar Week
String | getDayOfWeekString1(Calendar currentDate) Method getDayOfWeekString1. int temp = getDayOfWeek(currentDate); String result = ""; switch (temp) { case Calendar.MONDAY: result = "A"; break; case Calendar.TUESDAY: result = "B"; ... |
Date | getEndOfWeek(Calendar calendar, Date date, int dayStartOfWeek) get End Of Week ensureStateValid(calendar, date); calendar.setTime(date); setDateToZeroHour(calendar); do { calendar.add(Calendar.DATE, 1); } while (calendar.get(Calendar.DAY_OF_WEEK) != dayStartOfWeek); calendar.add(Calendar.MILLISECOND, -1); return calendar.getTime(); ... |
int | getFirstDateInMonthForDayOfWeek(Calendar cal, final int dayOfWeek) get First Date In Month For Day Of Week Calendar tmpCal = new GregorianCalendar(cal.getTimeZone()); tmpCal.set(Calendar.YEAR, cal.get(Calendar.YEAR)); tmpCal.set(Calendar.MONTH, cal.get(Calendar.MONTH)); tmpCal.set(Calendar.DATE, 1); int day = tmpCal.get(Calendar.DAY_OF_WEEK); if (day == dayOfWeek) { return tmpCal.get(Calendar.DATE); while (day != dayOfWeek) { tmpCal.add(Calendar.DATE, 1); day = tmpCal.get(Calendar.DAY_OF_WEEK); return tmpCal.get(Calendar.DATE); |
Calendar | getFirstDayOfWeek(Calendar cal) get First Day Of Week switch (cal.get(Calendar.DAY_OF_WEEK)) { case 1: break; case 2: cal.add(Calendar.DATE, -1); break; case 3: cal.add(Calendar.DATE, -2); ... |
Calendar | getFirstDayOfWeek(Calendar calendar) get First Day Of Week Calendar ret = (Calendar) calendar.clone();
ret.add(Calendar.DAY_OF_MONTH, -((ret.get(Calendar.DAY_OF_WEEK) + 5) % 7));
return ret;
|
int | getFirstOfMonthDayOfWeek(GregorianCalendar aCalendar) Gets the day of the week for the first day of the month. int currDom = aCalendar.get(Calendar.DAY_OF_MONTH); aCalendar.set(Calendar.DAY_OF_MONTH, 1); int firstDowInMonth = aCalendar.get(Calendar.DAY_OF_WEEK); aCalendar.set(Calendar.DAY_OF_MONTH, currDom); return firstDowInMonth; |
Calendar | getImmediateDayOfWeek(Calendar current, int dayOfWeek) get Immediate Day Of Week Calendar immediateDayOfWeek = (Calendar) current.clone(); immediateDayOfWeek.add(Calendar.DAY_OF_MONTH, 1); while (immediateDayOfWeek.get(Calendar.DAY_OF_WEEK) != dayOfWeek) { immediateDayOfWeek.add(Calendar.DAY_OF_MONTH, 1); return immediateDayOfWeek; |
int | getLastDayOfWeek(Calendar cal) get Last Day Of Week int last = cal.getFirstDayOfWeek() - 1; if (last == 0) { last = Calendar.SATURDAY; return last; |
int | getLastDayOfWeek(Calendar cal) get Last Day Of Week int firstDayOfWeek = cal.getFirstDayOfWeek(); if (firstDayOfWeek == Calendar.SUNDAY) { return Calendar.SATURDAY; } else if (firstDayOfWeek == Calendar.MONDAY) { return Calendar.SUNDAY; } else if (firstDayOfWeek == Calendar.TUESDAY) { return Calendar.MONDAY; } else if (firstDayOfWeek == Calendar.WEDNESDAY) { ... |
int | getWeek(Calendar calendar) get Week return calendar.get(Calendar.WEEK_OF_YEAR);
|