API usage
The API usage is very simple. Instantiate a HolidayManager by calling getInstance() for one country or one URL to a holiday xml file and use this manager to determine the holidays for a year/state/district.
Code Example
- To get a HolidayManager instance for US holidays:
HolidayManager m = HolidayManager.getInstance(HolidayCalendar.UNITED_STATES);
or
URL url = new URL("file:some/path/MyHolidays.xml");
HolidayManager m = HolidayManager.getInstance(url);
- To get the holidays for the state New York:
Set<Holiday> holidays = m.getHolidays(2010, "ny");
- To get the holidays for New York City in the state New York:
Set<Holiday> holidays = m.getHolidays(2010, "ny", "nyc");
- To get a HolidayManager instance for your own holidays:
- create a Holidays file i.e. Holidays_MyOwn.xml
- put your holiday rules into this (for examples please the XML files in the provided JAR file in the folder holidays)
- put your Holidays_MyOwn.xml in your applications classpath
- put your Holidays_MyOwn.xml somewhere and reference it by URL
- to use your holiday rules create an HolidayManager instance by calling HolidayManager m = HolidayManager.getInstance("MyOwn");
- to use your holiday rules create an HolidayManager instance by calling HolidayManager m = HolidayManager.getInstance(url);
- call Set<Holiday> holidays = m.getHolidays(2010); to retrieve the holidays for 2010.