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

  1. 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);
    
  2. To get the holidays for the state New York:
      Set<Holiday> holidays = m.getHolidays(2010, "ny");
  3. To get the holidays for New York City in the state New York:
      Set<Holiday> holidays = m.getHolidays(2010, "ny", "nyc");
  4. To get a HolidayManager instance for your own holidays:
    1. create a Holidays file i.e. Holidays_MyOwn.xml
    2. put your holiday rules into this (for examples please the XML files in the provided JAR file in the folder holidays)
    3. put your Holidays_MyOwn.xml in your applications classpath
    4. put your Holidays_MyOwn.xml somewhere and reference it by URL
    5. to use your holiday rules create an HolidayManager instance by calling HolidayManager m = HolidayManager.getInstance("MyOwn");
    6. to use your holiday rules create an HolidayManager instance by calling HolidayManager m = HolidayManager.getInstance(url);
    7. call Set<Holiday> holidays = m.getHolidays(2010); to retrieve the holidays for 2010.