Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
push:
branches:
- main
- 2.x
pull_request:
workflow_dispatch:

Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
push:
branches:
- main
- 2.x
pull_request:
workflow_dispatch:

Expand All @@ -17,7 +18,7 @@ jobs:
name: Build
strategy:
matrix:
java: [ '11', '17', '21', '25' ]
java: [ '17', '21', '25' ]
os: [ 'ubuntu-24.04', 'macos-14', 'windows-2022' ]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -41,13 +42,11 @@ jobs:
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Set up JDK 11 and 25
- name: Set up JDK from .tool-versions
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: |
11
25
java-version-file: ".tool-versions"
cache: 'maven'
- name: Run tests with JaxB
run: >
Expand All @@ -65,7 +64,6 @@ jobs:
-Dsonar.host.url=https://sonarcloud.io
-Dsonar.organization=focus-shift
-Dsonar.projectKey=focus-shift_jollyday
-Dsonar.java.jdkHome=${{ env.JAVA_HOME_11_X64 }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
8 changes: 6 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ name: "CodeQL"

on:
push:
branches: [ "main" ]
branches:
- main
- 2.x
pull_request:
branches: [ "main" ]
branches:
- main
- 2.x
schedule:
- cron: '42 5 * * 4'

Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
name: 'Dependency review'
on:
pull_request:
branches: [ "main" ]
branches:
- main
- 2.x
paths:
- '**/pom.xml'

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/release-trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ jobs:

- name: Build
run: ./mvnw verify

- name: Create Release Notes
uses: spring-io/github-changelog-generator@v0.0.12
with:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ jobs:

- name: Tests with Maven
run: ./mvnw verify

- name: Build with Maven
run: ./mvnw -Prelease -Drelease deploy
env:
Expand Down
2 changes: 1 addition & 1 deletion .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
wrapperVersion=3.3.4
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.11/apache-maven-3.9.11-bin.zip
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/4.0.0-rc-5/apache-maven-4.0.0-rc-5-bin.zip
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
java temurin-11.0.27+6
java temurin-17.0.15+6
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Jollyday is a java library to query public holidays. Currently, we support **ove

## How to use it

**Jollyday** is based on **Java 11** and can be used directly as dependency via maven or gradle e.g.
**Jollyday** is based on **Java 17** and can be used directly as dependency via maven or gradle e.g.
The calculation basis of the public holidays for each country is based on a xml file and will be mapped via Jakarta XML Binding or Jackson.
If you already use one of these libraries in your project than just use the specific jollyday dependency.

Expand Down Expand Up @@ -360,7 +360,7 @@ If you want to raise an **issue or bug** you can create a [new issue](https://gi

### Requirements

* [JDK 11](https://openjdk.java.net/install/)
* [JDK 17](https://openjdk.java.net/install/)

### Architecture decision record (ADR)

Expand Down
7 changes: 2 additions & 5 deletions jollyday-core/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<project xmlns="http://maven.apache.org/POM/4.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.1.0 https://maven.apache.org/xsd/maven-4.1.0.xsd">
<modelVersion>4.1.0</modelVersion>

<artifactId>jollyday-core</artifactId>
<name>Jollyday Core</name>
Expand All @@ -12,8 +11,6 @@
<parent>
<groupId>de.focus-shift</groupId>
<artifactId>jollyday</artifactId>
<version>1.8.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,7 @@ private Collection<HolidayParser> getParsers(final Holidays config) {
try {
final Method[] declaredMethods = config.getClass().getDeclaredMethods();
for (Method declaredMethod : declaredMethods) {
if (declaredMethod.getGenericReturnType() instanceof ParameterizedType) {
final ParameterizedType parameterizedType = (ParameterizedType) declaredMethod.getGenericReturnType();
if (declaredMethod.getGenericReturnType() instanceof ParameterizedType parameterizedType) {
final Type actualTypeArgument = parameterizedType.getActualTypeArguments()[0];
final List<?> holidays = (List<?>) declaredMethod.invoke(config);
if (!holidays.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,11 @@ public LocalDate apply(final FixedWeekdayRelativeToFixed fixedWeekdayRelativeToF
* @return the day moved to the weekday and in the direction as specified
*/
private LocalDate moveDateToFirstOccurrenceOfWeekday(final FixedWeekdayRelativeToFixed fixedWeekdayRelativeToFixed, final LocalDate day) {
final TemporalAdjuster adjuster;
switch (fixedWeekdayRelativeToFixed.when()) {
case AFTER:
adjuster = next(fixedWeekdayRelativeToFixed.weekday());
break;
case BEFORE:
adjuster = previous(fixedWeekdayRelativeToFixed.weekday());
break;
case CLOSEST:
adjuster = closest(fixedWeekdayRelativeToFixed.weekday());
break;
default:
throw new IllegalArgumentException("Unsupported relative adjustment: " + fixedWeekdayRelativeToFixed.when());
}
final TemporalAdjuster adjuster = switch (fixedWeekdayRelativeToFixed.when()) {
case AFTER -> next(fixedWeekdayRelativeToFixed.weekday());
case BEFORE -> previous(fixedWeekdayRelativeToFixed.weekday());
case CLOSEST -> closest(fixedWeekdayRelativeToFixed.weekday());
};
return day.with(adjuster);
}

Expand All @@ -66,16 +57,12 @@ private int determineNumberOfDays(final FixedWeekdayRelativeToFixed fixedWeekday
if (fixedWeekdayRelativeToFixed.when() == Relation.CLOSEST) {
return 0;
}
switch (fixedWeekdayRelativeToFixed.which()) {
case SECOND:
return 7;
case THIRD:
return 14;
case FOURTH:
return 21;
default:
return 0;
}
return switch (fixedWeekdayRelativeToFixed.which()) {
case SECOND -> 7;
case THIRD -> 14;
case FOURTH -> 21;
default -> 0;
};
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,60 +28,23 @@ public List<Holiday> parse(final Year year, final Holidays holidays) {

final LocalDate easterSunday = new CalculateEasterSunday(year).apply(christianHolidayConfiguration.chronology());

final LocalDate actualDate;
switch (christianHolidayConfiguration.type()) {
case EASTER:
actualDate = easterSunday;
break;
case CLEAN_MONDAY:
case SHROVE_MONDAY:
actualDate = easterSunday.minusDays(48);
break;
case MARDI_GRAS:
case CARNIVAL:
actualDate = easterSunday.minusDays(47);
break;
case ASH_WEDNESDAY:
actualDate = easterSunday.minusDays(46);
break;
case MAUNDY_THURSDAY:
actualDate = easterSunday.minusDays(3);
break;
case GOOD_FRIDAY:
actualDate = easterSunday.minusDays(2);
break;
case EASTER_SATURDAY:
actualDate = easterSunday.minusDays(1);
break;
case EASTER_MONDAY:
actualDate = easterSunday.plusDays(1);
break;
case EASTER_TUESDAY:
actualDate = easterSunday.plusDays(2);
break;
case GENERAL_PRAYER_DAY:
actualDate = easterSunday.plusDays(26);
break;
case ASCENSION_DAY:
actualDate = easterSunday.plusDays(39);
break;
case PENTECOST:
case WHIT_SUNDAY:
actualDate = easterSunday.plusDays(49);
break;
case WHIT_MONDAY:
case PENTECOST_MONDAY:
actualDate = easterSunday.plusDays(50);
break;
case CORPUS_CHRISTI:
actualDate = easterSunday.plusDays(60);
break;
case SACRED_HEART:
actualDate = easterSunday.plusDays(68);
break;
default:
throw new IllegalArgumentException("Unknown christian holiday type " + christianHolidayConfiguration.type());
}
final LocalDate actualDate = switch (christianHolidayConfiguration.type()) {
case EASTER -> easterSunday;
case CLEAN_MONDAY, SHROVE_MONDAY -> easterSunday.minusDays(48);
case MARDI_GRAS, CARNIVAL -> easterSunday.minusDays(47);
case ASH_WEDNESDAY -> easterSunday.minusDays(46);
case MAUNDY_THURSDAY -> easterSunday.minusDays(3);
case GOOD_FRIDAY -> easterSunday.minusDays(2);
case EASTER_SATURDAY -> easterSunday.minusDays(1);
case EASTER_MONDAY -> easterSunday.plusDays(1);
case EASTER_TUESDAY -> easterSunday.plusDays(2);
case GENERAL_PRAYER_DAY -> easterSunday.plusDays(26);
case ASCENSION_DAY -> easterSunday.plusDays(39);
case PENTECOST, WHIT_SUNDAY -> easterSunday.plusDays(49);
case WHIT_MONDAY, PENTECOST_MONDAY -> easterSunday.plusDays(50);
case CORPUS_CHRISTI -> easterSunday.plusDays(60);
case SACRED_HEART -> easterSunday.plusDays(68);
};

return new MoveDateRelative(actualDate).apply(christianHolidayConfiguration)
.map(observedDate -> new CreateHoliday(actualDate, observedDate))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,14 @@ public List<Holiday> parse(final Year year, final Holidays holidays) {
return holidays.ethiopianOrthodoxHolidays().stream()
.filter(new ValidLimitation(year))
.flatMap(eoh -> {
final Stream<LocalDate> ethiopianHolidays;
switch (eoh.type()) {
case TIMKAT:
ethiopianHolidays = new CalculateRelativeDatesFromChronologyWithinGregorianYear(5, 10, CopticChronology.INSTANCE, 0).apply(year);
break;
case ENKUTATASH:
ethiopianHolidays = new CalculateRelativeDatesFromChronologyWithinGregorianYear(1, 1, CopticChronology.INSTANCE, 0).apply(year);
break;
case MESKEL:
ethiopianHolidays = new CalculateRelativeDatesFromChronologyWithinGregorianYear(1, 17, CopticChronology.INSTANCE, 0).apply(year);
break;
default:
throw new IllegalArgumentException("Unknown ethiopian orthodox holiday type " + eoh.type());
}
final Stream<LocalDate> ethiopianHolidays = switch (eoh.type()) {
case TIMKAT ->
new CalculateRelativeDatesFromChronologyWithinGregorianYear(5, 10, CopticChronology.INSTANCE, 0).apply(year);
case ENKUTATASH ->
new CalculateRelativeDatesFromChronologyWithinGregorianYear(1, 1, CopticChronology.INSTANCE, 0).apply(year);
case MESKEL ->
new CalculateRelativeDatesFromChronologyWithinGregorianYear(1, 17, CopticChronology.INSTANCE, 0).apply(year);
};
return ethiopianHolidays.map(date -> new CreateHoliday(date).apply(eoh));
})
.collect(toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,57 +27,38 @@ public List<Holiday> parse(final Year year, final Holidays holidays) {
.filter(new ValidLimitation(year))
.flatMap(islamicHoliday -> {

final Stream<LocalDate> islamicHolidays;

switch (islamicHoliday.type()) {
case NEWYEAR:
islamicHolidays = new CalculateRelativeDatesFromChronologyWithinGregorianYear(1, 1, HijrahChronology.INSTANCE, 0).apply(year);
break;
case ASCHURA:
islamicHolidays = new CalculateRelativeDatesFromChronologyWithinGregorianYear(1, 10, HijrahChronology.INSTANCE, 0).apply(year);
break;
case RAMADAN_END:
islamicHolidays = new CalculateRelativeDatesFromChronologyWithinGregorianYear(10, 1, HijrahChronology.INSTANCE, -1).apply(year);
break;
case ID_AL_FITR:
islamicHolidays = new CalculateRelativeDatesFromChronologyWithinGregorianYear(10, 1, HijrahChronology.INSTANCE, 0).apply(year);
break;
case ID_AL_FITR_2:
islamicHolidays = new CalculateRelativeDatesFromChronologyWithinGregorianYear(10, 2, HijrahChronology.INSTANCE, 0).apply(year);
break;
case ID_AL_FITR_3:
islamicHolidays = new CalculateRelativeDatesFromChronologyWithinGregorianYear(10, 3, HijrahChronology.INSTANCE, 0).apply(year);
break;
case ARAFAAT:
islamicHolidays = new CalculateRelativeDatesFromChronologyWithinGregorianYear(12, 9, HijrahChronology.INSTANCE, 0).apply(year);
break;
case ID_UL_ADHA:
islamicHolidays = new CalculateRelativeDatesFromChronologyWithinGregorianYear(12, 10, HijrahChronology.INSTANCE, 0).apply(year);
break;
case ID_UL_ADHA_2:
islamicHolidays = new CalculateRelativeDatesFromChronologyWithinGregorianYear(12, 11, HijrahChronology.INSTANCE, 0).apply(year);
break;
case ID_UL_ADHA_3:
islamicHolidays = new CalculateRelativeDatesFromChronologyWithinGregorianYear(12, 12, HijrahChronology.INSTANCE, 0).apply(year);
break;
case LAILAT_AL_BARAT:
islamicHolidays = new CalculateRelativeDatesFromChronologyWithinGregorianYear(8, 15, HijrahChronology.INSTANCE, 0).apply(year);
break;
case LAILAT_AL_MIRAJ:
islamicHolidays = new CalculateRelativeDatesFromChronologyWithinGregorianYear(7, 27, HijrahChronology.INSTANCE, 0).apply(year);
break;
case LAILAT_AL_QADR:
islamicHolidays = new CalculateRelativeDatesFromChronologyWithinGregorianYear(9, 27, HijrahChronology.INSTANCE, 0).apply(year);
break;
case MAWLID_AN_NABI:
islamicHolidays = new CalculateRelativeDatesFromChronologyWithinGregorianYear(3, 12, HijrahChronology.INSTANCE, 0).apply(year);
break;
case RAMADAN:
islamicHolidays = new CalculateRelativeDatesFromChronologyWithinGregorianYear(9, 1, HijrahChronology.INSTANCE, 0).apply(year);
break;
default:
throw new IllegalArgumentException("Unknown islamic holiday " + islamicHoliday.type());
}
final Stream<LocalDate> islamicHolidays = switch (islamicHoliday.type()) {
case NEWYEAR ->
new CalculateRelativeDatesFromChronologyWithinGregorianYear(1, 1, HijrahChronology.INSTANCE, 0).apply(year);
case ASCHURA ->
new CalculateRelativeDatesFromChronologyWithinGregorianYear(1, 10, HijrahChronology.INSTANCE, 0).apply(year);
case RAMADAN_END ->
new CalculateRelativeDatesFromChronologyWithinGregorianYear(10, 1, HijrahChronology.INSTANCE, -1).apply(year);
case ID_AL_FITR ->
new CalculateRelativeDatesFromChronologyWithinGregorianYear(10, 1, HijrahChronology.INSTANCE, 0).apply(year);
case ID_AL_FITR_2 ->
new CalculateRelativeDatesFromChronologyWithinGregorianYear(10, 2, HijrahChronology.INSTANCE, 0).apply(year);
case ID_AL_FITR_3 ->
new CalculateRelativeDatesFromChronologyWithinGregorianYear(10, 3, HijrahChronology.INSTANCE, 0).apply(year);
case ARAFAAT ->
new CalculateRelativeDatesFromChronologyWithinGregorianYear(12, 9, HijrahChronology.INSTANCE, 0).apply(year);
case ID_UL_ADHA ->
new CalculateRelativeDatesFromChronologyWithinGregorianYear(12, 10, HijrahChronology.INSTANCE, 0).apply(year);
case ID_UL_ADHA_2 ->
new CalculateRelativeDatesFromChronologyWithinGregorianYear(12, 11, HijrahChronology.INSTANCE, 0).apply(year);
case ID_UL_ADHA_3 ->
new CalculateRelativeDatesFromChronologyWithinGregorianYear(12, 12, HijrahChronology.INSTANCE, 0).apply(year);
case LAILAT_AL_BARAT ->
new CalculateRelativeDatesFromChronologyWithinGregorianYear(8, 15, HijrahChronology.INSTANCE, 0).apply(year);
case LAILAT_AL_MIRAJ ->
new CalculateRelativeDatesFromChronologyWithinGregorianYear(7, 27, HijrahChronology.INSTANCE, 0).apply(year);
case LAILAT_AL_QADR ->
new CalculateRelativeDatesFromChronologyWithinGregorianYear(9, 27, HijrahChronology.INSTANCE, 0).apply(year);
case MAWLID_AN_NABI ->
new CalculateRelativeDatesFromChronologyWithinGregorianYear(3, 12, HijrahChronology.INSTANCE, 0).apply(year);
case RAMADAN ->
new CalculateRelativeDatesFromChronologyWithinGregorianYear(9, 1, HijrahChronology.INSTANCE, 0).apply(year);
};

return islamicHolidays
.map(date -> new DescribedDateHolder(islamicHoliday, date, new MoveDateRelative(date).apply(islamicHoliday).orElse(null)))
Expand Down
Loading
Loading