private static WeekDay findWeekDay(final String workingDay) { WeekDay[] weekDays = WeekDay.values(); // all weekdays for (WeekDay weekDay : weekDays) { if (weekDay.name().equalsIgnoreCase(workingDay)) { return weekDay; } } throw new RuntimeException( "The configured working day " + workingDay + " is not a week day enum."); }
public List<Days> getWorkingDaysAsJodaTimeDays() { List<Days> jodaWorkingDays = new ArrayList<Days>(); List<WeekDay> workingDaysAsWeekDays = getWorkingDays(); for (WeekDay weekDay : workingDaysAsWeekDays) { Days jodaWeekDay = Days.days(WeekDay.getJodaDayOfWeekThatMatchesMifosWeekDay(weekDay.getValue())); jodaWorkingDays.add(jodaWeekDay); } return jodaWorkingDays; }
public boolean isWorkingDay(final Short dayOfWeek) { if (configWorkingDays == null) { throw new RuntimeException("The working days are not defined in the config file."); } WeekDay weekDay = WeekDay.getWeekDay(dayOfWeek); return isWorkingDay(weekDay); }
public List<WeekDay> getWeekDaysList() { WeekDay[] weekDays = WeekDay.values(); List<WeekDay> list = new ArrayList<WeekDay>(); for (WeekDay weekDay : weekDays) { list.add(weekDay); } return list; }
private boolean isWorkingDay(final WeekDay weekDay) { for (String configWorkingDay : configWorkingDays) { if (configWorkingDay.equalsIgnoreCase(weekDay.name())) { return true; } } return false; }
public List<Short> getWeekDayOffList() { if (configWorkingDays == null) { throw new RuntimeException("The working days are not defined in the config file."); } List<Short> offDays = new ArrayList<Short>(); // returned Non-working days WeekDay[] weekDays = WeekDay.values(); for (int i = 0; i < weekDays.length; i++) { if (!isWorkingDay(weekDays[i])) { offDays.add(weekDays[i].getValue()); } } return offDays; }
public boolean isWorkingDay(final Calendar day) { if (configWorkingDays == null) { throw new RuntimeException("The working days are not defined in the config file."); } return isWorkingDay(WeekDay.getWeekDay(day.get(Calendar.DAY_OF_WEEK))); }