Skip to content

Commit

Permalink
Merge pull request #388 from focus-shift/267-iso-3166-2
Browse files Browse the repository at this point in the history
Use ISO 3166-2 to identify the country and the subdivisions
  • Loading branch information
derTobsch committed Dec 6, 2023
2 parents 3aab03e + 3f160f4 commit e475260
Show file tree
Hide file tree
Showing 43 changed files with 6,832 additions and 4,117 deletions.
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

Jollyday is a java library to query public holidays. Currently, we support **over 70 countries**.

Thanks to @svendiedrichsen who started jollyday!

## How to use it

**Jollyday** is based on **Java 11** and can be used directly as dependency via maven or gradle e.g.
Expand Down Expand Up @@ -167,6 +165,19 @@ If you already use one of these libraries in your project than just use the spec
```
</details>

## ISO 3166

To retrieve the public holidays of a country the [ISO 3166-1 alpha-2] standard is used. An [list of current ISO 3166-1 alpha-2 codes] is available at wikipedia.

To access the public holidays of a subdivision of a country, e.g. Baden-Württemberg of Germany the [ISO 3166-2] standard is used. A [list of current ISO 3166-2 codes] is available at wikipedia.

### Data precision

| Precision | Supported |
|--------------------------------|-----------|
| Country ([ISO 3166-1 alpha-2]) | Yes |
| Subdivisions ([ISO 3166-2]) | Yes |
| City Holiday | Yes |

## Development

Expand Down Expand Up @@ -201,3 +212,7 @@ or for Windows user:
[Apache License, Version 2.0](LICENSE.md)

[Discussions]: https://github.com/focus-shift/jollyday/discussions
[ISO 3166-1 alpha-2]: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
[list of current ISO 3166-1 alpha-2 codes]: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Current_codes
[ISO 3166-2]: https://en.wikipedia.org/wiki/ISO_3166-2
[list of current ISO 3166-2 codes]: https://en.wikipedia.org/wiki/ISO_3166-2#Current_codes
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
/**
* This enum provides a list of all supported holiday calendars.
*
* @author Sven Diedrichsen ([email protected])
* @version $Id$
*/
public enum HolidayCalendar {
Expand Down Expand Up @@ -47,5 +46,4 @@ public enum HolidayCalendar {
public String getId() {
return id;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ public String getCountryDescription(Locale l, String key) {
* @return 2-digit ISO codes.
*/
public Set<String> getISOCodes() {
Set<String> codes = new HashSet<>();
ResourceBundle countryDescriptions = getCountryDescriptions(Locale.getDefault());
final Set<String> codes = new HashSet<>();
final ResourceBundle countryDescriptions = getCountryDescriptions(Locale.getDefault());
for (String property : Collections.list(countryDescriptions.getKeys())) {
String[] split = property.split("\\.");
final String[] split = property.split("\\.");
if (split.length > 2) {
codes.add(split[2].toLowerCase());
}
Expand Down
Loading

0 comments on commit e475260

Please sign in to comment.