List of utility methods to do Week Calculate
int | getWeekOfDate(Date date) get Week Of Date Calendar c = Calendar.getInstance();
c.setTime(date);
return c.get(Calendar.DAY_OF_WEEK);
|
int | getWeekOfYear(Date date, Locale locale) get Week Of Year Calendar c = new GregorianCalendar(locale); c.setTime(date); return c.get(Calendar.WEEK_OF_YEAR); |
int | getWeeksAddCount(int repType, int repIndex) Gets count of weeks to add, when repetition was chosen. int weekNum = new GregorianCalendar().get(Calendar.WEEK_OF_YEAR); int add = 0; if (repType == 0) add = 1; if ((repType == 1 && weekNum % 2 == 1) || (repType == 2 && weekNum % 2 == 0)) { add = 2; if ((repType == 1 && weekNum % 2 == 0) || (repType == 2 && weekNum % 2 == 1)) { ... |
int | getWeeksInYear(int year) get Weeks In Year Calendar c = new GregorianCalendar(); c.set(year, 11, 31); return c.get(Calendar.WEEK_OF_YEAR) == 53 ? 53 : 52; |
boolean | isSameWeekDates(Date date1, Date date2) is Same Week Dates Calendar cal1 = Calendar.getInstance(); Calendar cal2 = Calendar.getInstance(); cal1.setTime(date1); cal2.setTime(date2); int subYear = cal1.get(Calendar.YEAR) - cal2.get(Calendar.YEAR); if (0 == subYear) { if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR)) return true; ... |
Date | nextWeek(Date date, int week) next Week Calendar cal = Calendar.getInstance(); if (date != null) { cal.setTime(date); cal.add(Calendar.WEEK_OF_MONTH, week); return cal.getTime(); |
long | nextWeek(long date) Returns the week after date .
return addDays(date, 7);
|
Date | plusHour(Date date, int plusWeek) plus Hour return plusInteger(date, Calendar.HOUR, plusWeek);
|
Date | startOfWeek(Date datum) start Of Week if (datum == null) { return null; Calendar c = new GregorianCalendar(); c.setTime(datum); while (c.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) { c.setTime(addDays(c.getTime(), -1)); return startOfDay(c.getTime()); |
GregorianCalendar | weekCal(int weekNumber) week Cal int yearNum = INITIAL_YEAR + (weekNumber / 52); int weekNum = weekNumber % 52; GregorianCalendar cal = new GregorianCalendar(); cal.set(Calendar.YEAR, yearNum); cal.set(Calendar.WEEK_OF_YEAR, weekNum); return weekStart(cal); |