List of utility methods to do Week Day
boolean | isWeekendToday() is Weekend Today Calendar calendar = Calendar.getInstance(); int week = calendar.get(Calendar.DAY_OF_WEEK); return week == 1 || week == 7; |
int | lastDayOfWeek(int year, int month) last Day Of Week Date lastDate = new Date(year - 1900, month - 1, days(year, month)); return lastDate.getDay(); |
Date | nextDayAndHour(int dayOfTheWeek, int hour) next Day And Hour Calendar cal = new GregorianCalendar(); cal.setTimeInMillis(System.currentTimeMillis()); if (cal.get(Calendar.DAY_OF_WEEK) > dayOfTheWeek || (cal.get(Calendar.DAY_OF_WEEK) == dayOfTheWeek && cal.get(Calendar.HOUR_OF_DAY) >= hour)) { cal.add(Calendar.WEEK_OF_YEAR, 1); cal.set(Calendar.DAY_OF_WEEK, dayOfTheWeek); cal.set(Calendar.HOUR_OF_DAY, hour); ... |
Date | nextTwoWeeksFromToday() next Two Weeks From Today return addDays(new Date(), 14); |
Date | nextWeekday(int weekday, int hour, int minute, int second) next Weekday Calendar now = now(); int day = now.get(Calendar.DAY_OF_MONTH) + (7 - now.get(Calendar.DAY_OF_WEEK)) + weekday; return year(now.get(Calendar.MONTH), day, hour, minute, second); |
String | parseToEntireWeekCaption(String startDay, String pattern) parse To Entire Week Caption SimpleDateFormat sdf = new SimpleDateFormat(pattern); Calendar calendar = new GregorianCalendar(2012, Calendar.JANUARY, 1); calendar.setTime(sdf.parse(startDay)); calendar.add(Calendar.DAY_OF_MONTH, 6); String endDay = sdf.format(calendar.getTime()); return startDay + "~" + endDay; |
Date | plusDay(Date date, int plusWeek) plus Day return plusInteger(date, Calendar.DAY_OF_MONTH, plusWeek);
|
void | toDayOfWeekInMonth(Calendar c, int dayOfWeek, int weekInMonth) Takes you to eg the 2nd Thursday in the month, which may involve going back before the current date c.set(Calendar.DATE, 1); c.set(Calendar.DAY_OF_WEEK, dayOfWeek); c.set(Calendar.DAY_OF_WEEK_IN_MONTH, weekInMonth); |
Date | weekDay(int week) week Day Calendar cal = calendar();
cal.set(Calendar.DAY_OF_WEEK, week);
return cal.getTime();
|
String | weekday(String date) weekday Calendar calendar = Calendar.getInstance(); DateFormat dateFormat = DateFormat.getDateInstance(); Date da = null; da = dateFormat.parse(date); calendar.setTime(da); int num = calendar.get(Calendar.DAY_OF_WEEK); if (num == 1) { num = 7; ... |