List of utility methods to do Day of Week
Date | getLastWeekDate(Date date) get Last Week Date Calendar c = getCalendar();
c.setTime(date);
c.add(Calendar.WEEK_OF_YEAR, -1);
return c.getTime();
|
Date | getLastWeekDay(int weekDay, Date end) get Last Week Day if (end == null) throw new IllegalArgumentException("The parameter [end date] should not be null!"); GregorianCalendar cal = getCalender(end); cal.set(Calendar.DAY_OF_WEEK, weekDay); if (!cal.getTime().before(end)) { cal.add(Calendar.DAY_OF_MONTH, -7); return cal.getTime(); ... |
Date | getMondayFirstOfWeek(Date baseDate) get Monday First Of Week int dayofweek = getDayOfWeekForDate(baseDate); dayofweek = dayofweek == 1 ? dayofweek + 7 : dayofweek; return getDateAfterDays(baseDate, 2 - dayofweek); |
Date | getMondayOfThisWeek(Date date) get Monday Of This Week Calendar c = Calendar.getInstance(); c.setTime(date); int day_of_week = c.get(Calendar.DAY_OF_WEEK) - 1; if (day_of_week == 0) day_of_week = 7; c.add(Calendar.DATE, -day_of_week + 1); return c.getTime(); |
Date | getMondayOfWeek(Date date) get Monday Of Week Calendar monday = Calendar.getInstance();
monday.setTime(date);
monday.setFirstDayOfWeek(FIRST_DAY_OF_WEEK);
monday.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
return monday.getTime();
|
java.util.Date | getNext(final java.util.Date date, final int dayofweek) get Next final GregorianCalendar gc = new GregorianCalendar(); gc.setTime(date); final int actualday = gc.get(Calendar.DAY_OF_WEEK); gc.add(Calendar.DATE, ((dayofweek - actualday + WEEK_DAYS) % WEEK_DAYS)); return gc.getTime(); |
LocalDateTime | getNextClosestDateTime(DayOfWeek[] daysOfWeek, int hour, int min) Gets the next or same closest date from the specified days in daysOfWeek Array at specified hour and min . return getNextClosestDateTime(Arrays.asList(daysOfWeek), hour, min);
|
LocalDateTime | getNextClosestDateTime(DayOfWeek[] daysOfWeek, int hour, int min) Gets the next or same closest date from the specified days in daysOfWeek Array at specified hour and min . return getNextClosestDateTime(Arrays.asList(daysOfWeek), hour, min);
|
long | getNextDay(long date, int startOfWeek) Returns the first day after date that has the day of week matching startOfWeek .
return getDay(date, startOfWeek, 1);
|
Date | getNextWeekDay(Date startDate, int day) get Next Week Day Calendar strDate = Calendar.getInstance();
strDate.setFirstDayOfWeek(Calendar.MONDAY);
strDate.setTime(startDate);
strDate.add(Calendar.WEEK_OF_YEAR, 1);
strDate.set(Calendar.DAY_OF_WEEK, day);
return strDate.getTime();
|