Пример #1
0
  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.");
  }
Пример #2
0
  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;
  }
Пример #3
0
 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);
 }
Пример #4
0
 public List<WeekDay> getWeekDaysList() {
   WeekDay[] weekDays = WeekDay.values();
   List<WeekDay> list = new ArrayList<WeekDay>();
   for (WeekDay weekDay : weekDays) {
     list.add(weekDay);
   }
   return list;
 }
Пример #5
0
 private boolean isWorkingDay(final WeekDay weekDay) {
   for (String configWorkingDay : configWorkingDays) {
     if (configWorkingDay.equalsIgnoreCase(weekDay.name())) {
       return true;
     }
   }
   return false;
 }
Пример #6
0
 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;
 }
Пример #7
0
 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)));
 }