It is almost certain that you will want to create a custom holiday calendar. You might want to use a central database, library or service which already contains up to date holidays.
The default holiday calendar provided with jFin just marks weekends (Sat/Sun) as holidays, and is primarily used for consistent testing.
The jFin package also provides a holiday calendar implementation which reads financialcalendar.com tri-col files in the package org.jfin.date.holiday.financialcalendarimpl.
You should always use the abstract factory HolidayCalendarFactory to get the concrete implementation of the HolidayCalendar.
After trying out this recipe, the default and financialcalendar.com implementations should provide you with a good starting point for your own calendars.
To create your own holiday calendar you need to implement (at least) two classes;
Your factory needs to implements two methods from the abstract HolidayCalendarFactory class:
public HolidayCalendar getHolidayCalendar(String locale);
and
public String[] getAvailableLocales();
The getHolidayCalendar method returns the right HolidayCalendar object, set up as necessary, for the requested locale. The getAvailableLocales method returns an array containing the names of valid locales for this factory.
The actual implementation of the HolidayCalendar only needs to implement two methods:
public boolean isWeekend(Calendar d);
and
public boolean isHoliday(Calendar d)
And that's it.
You can set the default holiday calendar returned by HolidayCalendarFactory.newInstance() with the system property jfin.HolidayCalendarFactory. You can also use the HolidayCalendarFactory.newInstance(String holidayCalendarFactoryClassName) method.
This allows you to either alter the holiday calendar implementation when you run your application, at runtime, or even use different implementations side by side in the same process.
Three classes are provided for this recipe: