Improving toString by removal of weekend cal. Removed 31.12 (bug).
@@ -17,12 +17,12 @@ import java.time.LocalDate;
public class BusinessdayCalendarExcludingTARGETHolidays extends BusinessdayCalendar {
private BusinessdayCalendarInterface baseCalendar;
+ private final BusinessdayCalendarInterface weekdayCalendar = new BusinessdayCalendarExcludingWeekends();
/**
* Create business day calendar.
*/
public BusinessdayCalendarExcludingTARGETHolidays() {
- this.baseCalendar = new BusinessdayCalendarExcludingWeekends();
}
/**
@@ -31,28 +31,22 @@ public class BusinessdayCalendarExcludingTARGETHolidays extends BusinessdayCalen
* @param baseCalendar Calendar of business days.
*/
public BusinessdayCalendarExcludingTARGETHolidays(BusinessdayCalendarInterface baseCalendar) {
- this.baseCalendar = new BusinessdayCalendarExcludingWeekends(baseCalendar);
+ this.baseCalendar = baseCalendar;
}
- /* (non-Javadoc)
- * @see net.finmath.time.BusinessdayCalendarInterface#isBuisinessday(java.time.LocalDate)
- */
@Override
public boolean isBusinessday(LocalDate date) {
int day = date.getDayOfMonth();
int month = date.getMonthValue();
- LocalDate datePlus2 = date.plusDays(2);
- LocalDate dateBefore = date.minusDays(1);
-
- return (baseCalendar == null || baseCalendar.isBusinessday(date))
+ return weekdayCalendar.isBusinessday(date)
+ && (baseCalendar == null || baseCalendar.isBusinessday(date))
&& !(day == 1 && month == 1) // date is New Year
+ && !isEasterSunday(date.plusDays(2)) // date is Good Friday
+ && !isEasterSunday(date.minusDays(1)) // date is Easter Monday
+ && !(day == 1 && month == 5) // date is Labour Day
&& !(day == 25 && month == 12) // date is Christmas
&& !(day == 26 && month == 12) // date is Boxing Day
- && !(day == 31 && month == 12)
- && !(day == 1 && month == 5) // date is Labour Day
- && !isEasterSunday(datePlus2) // date is Good Friday
- && !isEasterSunday(dateBefore) // date is Easter Monday
;
}
