/** Returns a list of all days occurring between startInclusive and endInclusive */ private static List<DayOfWeek> parseDays(String startInclusive, String endInclusive) { DayOfWeek start = dayFrom(startInclusive); DayOfWeek end = dayFrom(endInclusive); if (end.getValue() < start.getValue()) { throw new IllegalArgumentException(String.format("Invalid day range '%s-%s'", startInclusive, endInclusive)); } return IntStream.rangeClosed(start.getValue(), end.getValue()).boxed() .map(DayOfWeek::of) .collect(Collectors.toList()); }