}
return day;
}
private Holiday parseHoliday(Element holidayElement, DateFormat dayFormat, BusinessCalendarImpl businessCalendarImpl, Parse parse) {
Holiday holiday = new Holiday();
try {
if (holidayElement.hasAttribute("period")) {
String holidayPeriodText = holidayElement.getAttribute("period");
int dashIndex = holidayPeriodText.indexOf('-');
String fromDateText = null;
String toDateText = null;
if (dashIndex!=-1) {
fromDateText = holidayPeriodText.substring(0, dashIndex).trim().toLowerCase();
toDateText = holidayPeriodText.substring(dashIndex+1).trim().toLowerCase();
} else {
fromDateText = holidayPeriodText.trim().toLowerCase();
toDateText = fromDateText;
}
Date fromDate = dayFormat.parse(fromDateText);
holiday.setFromDay(fromDate);
Date toDate = dayFormat.parse(toDateText);
holiday.setToDay(toDate);
} else {
parse.addProblem("attribute 'period' in element business-calendar is required", holidayElement);
}
// now we are going to set the toDay to the end of the day, rather then the beginning.
// we take the start of the next day as the end of the toDay.
Calendar calendar = businessCalendarImpl.createCalendar();
calendar.setTime(holiday.getToDay());
calendar.add(Calendar.DATE, 1);
Date toDay = calendar.getTime();
holiday.setToDay(toDay);
} catch (Exception e) {
parse.addProblem("couldn't parse holiday: "+XmlUtil.toString(holidayElement), holidayElement);
}