/** * Moves the day to the first/next occurrence of the weekday and direction specified * @param f the specification of the weekday and direction of movement * @param day the day to move * @return the day moved to the weekday and in the direction as specified */ private LocalDate moveDateToFirstOccurrenceOfWeekday(FixedWeekdayRelativeToFixed f, LocalDate day) { final DayOfWeek weekday = xmlUtil.getWeekday(f.getWeekday()); return day.with(f.getWhen() == When.AFTER ? next(weekday) : previous(weekday)); }