Missing days for german federals
Closed this issue · 6 comments
Describe the bug
Looks like jollyday ignores the federals in germany.
To Reproduce
Using the following example code:
package org.example;
import de.focus_shift.Holiday;
import de.focus_shift.HolidayManager;
import java.time.LocalDate;
import java.util.Set;
public class Main
{
public static void main(String[] args)
{
HolidayManager holidayManager = HolidayManager.getInstance();
Set<Holiday> days = holidayManager.getHolidays(
LocalDate.of(2023,1,1),
LocalDate.of(2023,12,30),
"de", "bw"
);
System.out.println("\n" + days.size() + " of 12 days found:");
for( Holiday tag: days )
{
System.out.println( tag.toString() );
}
// Fixed: 6th of january
System.out.println( "Heilige drei Könige: " +
holidayManager.isHoliday(LocalDate.of(2023, 1, 6), "de", "bw") );
// Moving: 60 days after Christ's resurrection day
System.out.println( "Fronleichnam: " +
holidayManager.isHoliday(LocalDate.of(2023, 6, 8), "de", "bw") );
}
}
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>test_jollyday</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>19</maven.compiler.source>
<maven.compiler.target>19</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>de.focus-shift</groupId>
<artifactId>jollyday-jaxb</artifactId>
<version>0.16.0</version>
</dependency>
</dependencies>
</project>
yields:
9 of 12 days found:
2023-05-01 (Tag der Arbeit)
2023-04-10 (Ostermontag)
2023-04-07 (Karfreitag)
2023-01-01 (Neujahr)
2023-05-18 (Christi Himmelfahrt)
2023-05-29 (Pfingstmontag)
2023-10-03 (Tag der Deutschen Einheit)
2023-12-25 (1. Weihnachtsfeiertag)
2023-12-26 (2. Weihnachtsfeiertag)
Heilige drei Könige: false
Fronleichnam: false
while these days are defined in the xml (Holidays_de.xml:52):
<tns:SubConfigurations hierarchy="bw" description="Baden-Württemberg">
<tns:Holidays>
<tns:Fixed month="JANUARY" day="6" descriptionPropertiesKey="EPIPHANY"/>
<tns:Fixed month="NOVEMBER" day="1" descriptionPropertiesKey="ALL_SAINTS"/>
<tns:RelativeToFixed validFrom="1945" validTo="1989" descriptionPropertiesKey="REPENTANCE_PRAYER">
<tns:Weekday>WEDNESDAY</tns:Weekday>
<tns:When>BEFORE</tns:When>
<tns:Date month="NOVEMBER" day="23"/>
</tns:RelativeToFixed>
<tns:ChristianHoliday type="CORPUS_CHRISTI" descriptionPropertiesKey="christian.CORPUS_CHRISTI"/>
</tns:Holidays>
</tns:SubConfigurations>
Desktop (please complete the following information):
- OS: Windows 10
- Java: temurin-19.0.2
- jollyday: 0.16.0 installed via maven
Hey @terwarf,
thanks for your issue. Did you write a example project? Can you upload it to GitHub and send me a link to it? That would be great.
Hi @derTobsch,
sure, here you go:
https://github.com/terwarf/jollyday_demo_missing_holidys_de_bw
Thanks for looking into that issue.
Hey @terwarf,
this is because the readme is terribly wrong, how to retrieve the public holidays. Thanks for pointing that out.
You need to declare a HolidayManager
with the correct parameters and not providing the country as args parameter.
It should be like this e.g.
HolidayManager holidayManager = HolidayManager.getInstance(ManagerParameters.create(GERMANY));
Set<Holiday> days = holidayManager.getHolidays(
LocalDate.of(2023,1,1),
LocalDate.of(2023,12,30),
"bw"
);
otherwise the fallback is the us as country and therefore you cannot retrieve any German public holidays
I improved the readme as a quick fix. I think I should add more examples so that it will be clearer how to use the api. Also add more Javadoc.
@derTobsch Thanks a lot for the clarification. Now I get the expected results. 👍