List of utility methods to do Week Day
String[] | getWeekdays(DateFormatSymbols symbols) get Weekdays String[] weekdays = new String[7];
String[] localeWeekdays = symbols.getShortWeekdays();
weekdays[0] = localeWeekdays[Calendar.MONDAY];
weekdays[1] = localeWeekdays[Calendar.TUESDAY];
weekdays[2] = localeWeekdays[Calendar.WEDNESDAY];
weekdays[3] = localeWeekdays[Calendar.THURSDAY];
weekdays[4] = localeWeekdays[Calendar.FRIDAY];
weekdays[5] = localeWeekdays[Calendar.SATURDAY];
...
|
String | getWeekDayStr(int dayInWeek) get Week Day Str StringBuffer dateStr = new StringBuffer(); switch (dayInWeek) { case Calendar.MONDAY: dateStr.append("Monday"); break; case Calendar.TUESDAY: dateStr.append("Tuesday"); break; ... |
int[] | getWeekendDays(Locale locale) get Weekend Days if (THU_FRY_WEEKEND_DAYS_COUNTRIES.contains(locale.getCountry())) { return new int[] { Calendar.THURSDAY, Calendar.FRIDAY }; } else if (FRY_SUN_WEEKEND_DAYS_COUNTRIES.contains(locale.getCountry())) { return new int[] { Calendar.FRIDAY, Calendar.SUNDAY }; } else if (FRY_WEEKEND_DAYS_COUNTRIES.contains(locale.getCountry())) { return new int[] { Calendar.FRIDAY }; } else if (SUN_WEEKEND_DAYS_COUNTRIES.contains(locale.getCountry())) { return new int[] { Calendar.SUNDAY }; ... |
Date | getWeekFirstDay(Date date) get Week First Day Calendar c = Calendar.getInstance(); c.setTime(date); int year = c.get(Calendar.YEAR); int week = c.get(Calendar.WEEK_OF_YEAR); c.clear(); c.set(Calendar.YEAR, year); c.set(Calendar.WEEK_OF_YEAR, week); c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); ... |
boolean | isDayOfWeek(int day) is Day Of Week Calendar strDate = Calendar.getInstance(); if ((strDate.get(Calendar.DAY_OF_WEEK) - 1) == day) { return true; return false; |
boolean | isDayOfWeek(String str, int dayOfWeek) is Day Of Week int day = getCalendar(str).get(Calendar.DAY_OF_WEEK); if (day == dayOfWeek) return true; else return false; |
boolean | isFirseDayOfCurrentWeek(Date date) is Firse Day Of Current Week SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_WEEK, 2); Date firstDate = calendar.getTime(); return sdf.format(date).equals(sdf.format(firstDate)); |
int | isoDayOfWeek(int javaDayOfWeek) iso Day Of Week switch (javaDayOfWeek) { case Calendar.MONDAY: return 1; case Calendar.TUESDAY: return 2; case Calendar.WEDNESDAY: return 3; case Calendar.THURSDAY: ... |
boolean | isWeekday(String dateStr, String format) is Weekday Date date = parse(dateStr, format);
return date != null && isWeekday(date);
|
boolean | isWeekendDay(String strDay, DateFormat dateFormatter) Determines if a day is a day of the weekend, i.e., Saturday or Sunday final Calendar Day = Calendar.getInstance(); Day.setTime(dateFormatter.parse(strDay)); final int weekday = Day.get(Calendar.DAY_OF_WEEK); return weekday == 1 || weekday == 7; |