| name | Register Holiday Calendar |
| description | Register a new holiday calendar in the HolidayCalendar enum |
How to Register a Holiday Calendar
This guide explains how to register a new country calendar in the HolidayCalendar enum.
File Location
Edit: jollyday-core/src/main/java/de/focus_shift/jollyday/core/HolidayCalendar.java
Organization Pattern
The HolidayCalendar enum follows a strict organization pattern:
- Calendars are listed in alphabetical order by their ISO country code
- Each line starts with calendars beginning with a specific letter (A, B, C, etc.)
- Multiple calendars sharing the same starting letter are grouped on the same line alphabetically
Example Structure
public enum HolidayCalendar {
ANTARCTICA("AQ"), ALBANIA("AL"), ANDORRA("AD"), ARGENTINA("AR"), ARMENIA("AM"), AUSTRALIA("AU"), AUSTRIA("AT"),
BAHAMAS("BS"), BELARUS("BY"), BELGIUM("BE"), BERMUDA("BM"), BOLIVIA("BO"), BRAZIL("BR"), ...
CANADA(Locale.CANADA.getCountry()), CAYMAN_ISLANDS("KY"), ...
GERMANY("DE"), GREECE("GR"), ...
UNITED_STATES(Locale.US.getCountry()), ...
}
Steps to Add Your Calendar
1. Find the Correct Line
Identify which line your country code should appear on based on the first letter:
| First Letter | Example Calendars |
|---|
| A | ANTARCTICA, ALBANIA, ANDORRA, ARGENTINA, AUSTRALIA |
| B | BELARUS, BELGIUM, BERMUDA, BRAZIL |
| D | DENMARK, DOMINICAN, ECUADAR (E starts D line) |
2. Insert in Alphabetical Order
Add your calendar in alphabetical position within that letter group:
Before:
ALBANIA("AL"), ANDORRA("AD"), ARGENTINA("AR"),
Adding Antarctica (AQ) - after ARGENTINA:
ALBANIA("AL"), ANDORRA("AD"), ARGENTINA("AR"), ANTARCTICA("AQ"),
3. Use Correct Format
Format: COUNTRY_NAME("ISO_CODE")
Examples:
GERMANY("DE"),
CANADA(Locale.CANADA.getCountry()),
UNITED_STATES(Locale.US.getCountry()),
Complete Example
Adding a fictional "Zebra" country with code "ZB":
Before:
ZIMBABWE("ZW");
}
After:
ZEBRA("ZB"), ZIMBABWE("ZW");
}
Special Cases
Some countries use Java Locale instead of string codes:
CANADA(Locale.CANADA.getCountry()),
UNITED_STATES(Locale.US.getCountry()),
Best Practices
- Alphabetical order: Always maintain alphabetical order by ISO code
- Proper naming: Use full country name in uppercase with underscores
- ISO code: Use the official ISO 3166-1 alpha-2 code
- Comma placement: Add comma after each entry except the last
- Semicolon: Last entry ends with semicolon before closing brace
Verification
After adding your calendar, verify:
- The calendar is in the correct alphabetical position
- The ISO code matches the XML file's hierarchy attribute
- The Java file compiles without errors