Giter VIP home page Giter VIP logo

jollyday's Introduction

Jollyday Build Status Coverage Maven Central Javadocs

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

How to use it

Jollyday is based on Java 11 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.

Maven (click to expand)

You need the core library, that defines all functionality and the api for you as developer.

<dependency>
  <groupId>de.focus-shift</groupId>
  <artifactId>jollyday-core</artifactId>
  <version>${version}</version>
</dependency>

XML-Binding libraries

Additionally, the XML-Binding library of your choice. At the moment we do support JAXB and Jackson, but in the future there could be more that these.

Jakarta XML Binding (JAXB)

<dependency>
  <groupId>de.focus-shift</groupId>
  <artifactId>jollyday-jaxb</artifactId>
  <version>${version}</version>
</dependency>

Jackson

<dependency>
  <groupId>de.focus-shift</groupId>
  <artifactId>jollyday-jackson</artifactId>
  <version>${version}</version>
</dependency>
Gradle (click to expand)

You need the core library, that defines all functionality and the api for you as developer.

implementation group: 'de.focus-shift', name: 'jollyday-core', version: '${version}'

XML-Binding libraries

Additionally, the XML-Binding library of your choice. At the moment we do support JAXB and Jackson, but in the future there could be more that these.

Jakarta XML Binding (JAXB)

implementation group: 'de.focus-shift', name: 'jollyday-jaxb', version: '${version}'

Jackson

implementation group: 'de.focus-shift', name: 'jollyday-jackson', version: '${version}'
with the Java Platform Module System (click to expand)

If you want to use Jollyday in a project that is modularized via java modules you need to require the de.focus_shift.jollyday.core module via

module your.application {
  ...
  requires de.focus_shift.jollyday.core;
  ...
}

Examples

Retrieve public holidays for a year (click to expand)

Returns all german public holidays in 2022

import de.focus_shift.jollyday.core.Holiday;
import de.focus_shift.jollyday.core.HolidayManager;
import de.focus_shift.jollyday.core.ManagerParameters;

import java.util.Set;

import static de.focus_shift.jollyday.core.HolidayCalendar.GERMANY;

final HolidayManager holidayManager = HolidayManager.getInstance(ManagerParameters.create(GERMANY));
final Set<Holiday> holidays = holidayManager.getHolidays(2022);
Retrieve public holidays for a period of days (click to expand)

Returns all german public holidays from the 15th of april in 2022 until the 31st of may in 2023

import de.focus_shift.jollyday.core.Holiday;
import de.focus_shift.jollyday.core.HolidayManager;
import de.focus_shift.jollyday.core.ManagerParameters;

import java.time.LocalDate;
import java.util.Set;

import static de.focus_shift.jollyday.core.HolidayCalendar.GERMANY;

final HolidayManager holidayManager = HolidayManager.getInstance(ManagerParameters.create(GERMANY));
final Set<Holiday> holidays = holidayManager.getHolidays(LocalDate.of(2022, 4, 15), LocalDate.of(2023, 5, 31));
Check if a specific date is a public holiday (click to expand)

Returns true or false if a date is a public holidays in germany.

import de.focus_shift.jollyday.core.HolidayManager;
import de.focus_shift.jollyday.core.ManagerParameters;

import java.time.LocalDate;

import static de.focus_shift.jollyday.core.HolidayCalendar.GERMANY;

final HolidayManager holidayManager = HolidayManager.getInstance(ManagerParameters.create(GERMANY));
final boolean isHoliday = holidayManager.isHoliday(LocalDate.of(2022, 6, 6));

Returns true or false if a date is a public holidays in Baden-Württemberg in germany.

import de.focus_shift.jollyday.core.HolidayManager;
import de.focus_shift.jollyday.core.ManagerParameters;

import java.time.LocalDate;

import static de.focus_shift.jollyday.core.HolidayCalendar.GERMANY;

final HolidayManager holidayManager = HolidayManager.getInstance(ManagerParameters.create(GERMANY));
final boolean isHoliday = holidayManager.isHoliday(LocalDate.of(2022, 6, 6), "bw");
Override an existing country (click to expand)

If you want to override the public holidays of a provided country like germany, you need to put a holiday file with the name Holiday_de.xml on your classpath. Jollyday will pick up yours at first. The File and the hierarchy needs to be identical to the one you want to override.

The holiday file structure needs to look like the one below. The XML Schema Definition file can be viewed here

<?xml version="1.0" encoding="UTF-8"?>

<Configuration hierarchy="de" description="Germany"
               xmlns="https://focus_shift.de/jollyday/schema/holiday"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="https://focus_shift.de/jollyday/schema/holiday https://focus_shift.de/jollyday/schema/holiday/holiday.xsd">
  <Holidays>
    <!-- Add the holidays here-->
  </Holidays>

  ...
  
  <SubConfigurations hierarchy="bw" description="Baden-Württemberg">
    <Holidays>
    ...
    </Holidays>
  </SubConfigurations>
</Configuration>

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

If you want to support us at the development on jollyday than take a look at Contributing to jollyday. If you have any kind of questions please go to Discussions and see if there are already answers and if not please open a discussion with your question. If you want to raise an issue or bug you can create a new issue

Requirements

Architecture decision record (ADR)

License

Apache License, Version 2.0

jollyday's People

Contributors

cschneider avatar cwguenther avatar dependabot[bot] avatar dertobsch avatar dusiema avatar fanste avatar fkleon avatar focbenz avatar gebeater avatar github-actions[bot] avatar ivani3 avatar kattisa avatar malex211 avatar mfedkowicz avatar mliberato avatar netskeh avatar oleksandrshkurat avatar opensource21 avatar peffenberger avatar philipp-borchert-ish avatar raider2000 avatar rototor avatar samymohammed avatar sjmisterm avatar svendiedrichsen avatar thegreski avatar thomass4t avatar tr1ple-f avatar wborn avatar xspielinbox avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.