svendiedrichsen / jollyday

Jollyday - A holiday API
Other
186 stars 115 forks source link

Is there a way to access all State Holidays? #117

Closed MartinLiebig closed 4 years ago

MartinLiebig commented 4 years ago

Hi everyone,

is there anyway to access all state holidays of a given country? I would love to do something like

ManagerParameter pm = new CalendarPartManagerParameter(countryCode.toLowerCase(), null);
HolidayManager holidayManager = HolidayManager.getInstance(pm); 

for(String state : holidayManager.getSupportedStates()){
    Holiday day = holidayManager.getHolidays(year, state)
}

i've not found a way to do this, since there is not such a function like 'getSupportedStates() or so. Did i miss something?

Best, Martin

thackel commented 4 years ago

Use holidayManager.getCalendarHierarchy().getChildren() which contains the states. E.g. children.getDescription() contains the state and its childen all the holidays related to this state.

MartinLiebig commented 4 years ago

Thanks, worked like a charm!