@Test public void testTueAfter2ndMondayJuly() { Set<Holiday> result = new HashSet<>(); Holidays config = new Holidays(); RelativeToWeekdayInMonth rule = new RelativeToWeekdayInMonth(); rule.setWeekday(Weekday.TUESDAY); rule.setWhen(When.AFTER); FixedWeekdayInMonth date = new FixedWeekdayInMonth(); date.setWhich(Which.SECOND); date.setWeekday(Weekday.MONDAY); date.setMonth(Month.JULY); rule.setFixedWeekday(date); config.getRelativeToWeekdayInMonth().add(rule); rtwim.parse(2011, result, config); Assert.assertEquals("Wrong number of dates.", 1, result.size()); Assert.assertEquals( "Wrong date.", calendarUtil.create(2011, 7, 12), result.iterator().next().getDate()); }
/** * Implements the rule which requests if two holidays have one non holiday between each other than * this day is also a holiday. */ @Override public Set<Holiday> getHolidays(int year, final String... args) { Set<Holiday> holidays = super.getHolidays(year, args); Set<Holiday> additionalHolidays = new HashSet<Holiday>(); for (Holiday d : holidays) { LocalDate twoDaysLater = d.getDate().plusDays(2); if (CalendarUtil.contains(holidays, twoDaysLater)) { LocalDate bridgingDate = twoDaysLater.minusDays(1); additionalHolidays.add( new Holiday( bridgingDate, BRIDGING_HOLIDAY_PROPERTIES_KEY, LocalizedHolidayType.OFFICIAL_HOLIDAY)); } } holidays.addAll(additionalHolidays); return holidays; }