Brazilian Holidays: a Kotlin/Java library that provides resources to consult Brazilian holidays and business days

Overview

Release

Leia esta documentação em Português.

Brazilian Holidays

Brazilian Holidays is a Kotlin/Java library that provides resources to consult national holidays, bank holidays, business days, bank business days and dates of mobile religious events..

Dependency

Add the following to your build.gradle file:

repositories {
    mavenCentral()
    maven { url "https://jitpack.io" }
}

dependencies {
    implementation 'com.github.quantisbr:brazilian-holidays:1.0.0'
}

Or add the following to your build.gradle.kts:

repositories {
    mavenCentral()
    maven { url = uri("https://jitpack.io") }
}

dependencies {
    implementation("com.github.quantisbr:brazilian-holidays:1.0.0")
}

Or add the following to your pom.xml:

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

<dependency>
    <groupId>com.github.quantisbr</groupId>
    <artifactId>brazilian-holidays</artifactId>
    <version>1.0.0</version>
</dependency>

No other dependencies required.

Using

Access the example project here.

Get the date of a mobile religious event from the year

Kotlin:

val year = 2021
println("Carnival: " + year.toCarnivalDate())
println("Good Friday: " + year.toGoodFridayDate())
println("Easter: " + year.toEasterDate())
println("Corpus Christi: " + year.toCorpusChristiDate())

Java:

final int year = 2021;
System.out.println("Carnival: " + BrazilianHolidays.toCarnivalDate(year));
System.out.println("Good Friday: " + BrazilianHolidays.toGoodFridayDate(year));
System.out.println("Easter: " + BrazilianHolidays.toEasterDate(year));
System.out.println("Corpus Christi: " + BrazilianHolidays.toCorpusChristiDate(year));

Check if the date is a holiday

Kotlin:

val date = LocalDate.now()
if (date.isNationalHoliday())
    println("The '$date' is a holiday")
else
    println("The '$date' is not a holiday")

Java:

final LocalDate date = LocalDate.now();
if (BrazilianHolidays.isNationalHoliday(date))
    System.out.printf("The '%s' is a holiday%n", date);
else
    System.out.printf("The '%s' is not a holiday%n", date);

Check if the date is a bank public holiday

Kotlin:

val date = LocalDate.now()
if (date.isBankHoliday())
    println("The '$date' is a bank holiday")
else
    println("The '$date' is not a bank holiday")

Java:

final LocalDate date = LocalDate.now();
if (BrazilianHolidays.isBankHoliday(date))
    System.out.printf("The '%s' is a bank holiday%n", date);
else
    System.out.printf("The '%s' is not a bank holiday%n", date);

Check if the date is a business day

Kotlin:

val date = LocalDate.now()
if (date.isBusinessDay(false))
    println("The '$date' is a business day")
else
    println("The '$date' is not a business day")

Java:

final LocalDate date = LocalDate.now();
if (BrazilianHolidays.isBusinessDay(date, false))
    System.out.printf("The '%s' is a business day%n", date);
else
    System.out.printf("The '%s' is not a business day%n", date);

Check if the date is a bank business day

Kotlin:

val date = LocalDate.now()
if (date.isBankBusinessDay())
    println("The '$date' is a bank business day")
else
    println("The '$date' is not a bank business day")

Java:

final LocalDate date = LocalDate.now();
if (BrazilianHolidays.isBankBusinessDay(date))
    System.out.printf("The '%s' is a bank business day%n", date);
else
    System.out.printf("The '%s' is not a bank business day%n", date);

Count the number of business days in the date range

Kotlin:

import br.com.quantis.libraries.dates.DateRange
import br.com.quantis.libraries.dates.holidays.brazil.countBusinessDays
import java.time.LocalDate

...

val start = LocalDate.of(2019, 3, 12)
val end = LocalDate.of(2021, 11, 15)
val range = DateRange(start, end)
println("Number of business day: " + range.countBusinessDays())

Java:

import br.com.quantis.libraries.dates.DateRange;
import br.com.quantis.libraries.dates.holidays.brazil.BrazilianHolidays;
import java.time.LocalDate;

...

final LocalDate start = LocalDate.of(2019, 3, 12);
final LocalDate end = LocalDate.of(2021, 11, 15);
final DateRange range = new DateRange(start, end);

System.out.println("Number of business day: " + BrazilianHolidays.countBankBusinessDays(range));

Count the number of bank business days in the date range

Kotlin:

import br.com.quantis.libraries.dates.DateRange
import br.com.quantis.libraries.dates.holidays.brazil.countBankBusinessDays
import java.time.LocalDate

...

val start = LocalDate.of(2019, 3, 12)
val end = LocalDate.of(2021, 11, 15)
val range = DateRange(start, end)
println("Number of bank business day: " + range.countBankBusinessDays())

Java:

import br.com.quantis.libraries.dates.DateRange;
import br.com.quantis.libraries.dates.holidays.brazil.BrazilianHolidays;
import java.time.LocalDate;

...

final LocalDate start = LocalDate.of(2019, 3, 12);
final LocalDate end = LocalDate.of(2021, 11, 15);
final DateRange range = new DateRange(start, end);

System.out.println("Number of bank business day: " + BrazilianHolidays.countBankBusinessDays(range));
You might also like...
A modular and portable open source XMPP client library written in Java for Android and Java (SE) VMs

Smack About Smack is an open-source, highly modular, easy to use, XMPP client library written in Java for Java SE compatible JVMs and Android. Being a

ArchGuard Scanner for scan Git change history, scan source code by Chapi for Java, TypeScript, Kotlin, Go..、Java bytecode use for JVM languages, scan Jacoco test coverage.

Arch Scanner Requirements: JDK 12 Scanner: scan_git - Git commit history scan scan_jacoco - Jacoco scan scan_bytecode - for JVM languages known issues

Spantastic - an Android library that provides a simple and Kotlin fluent API for creating Android Spannable
Spantastic - an Android library that provides a simple and Kotlin fluent API for creating Android Spannable

Spantastic is an Android library that provides a simple and Kotlin fluent API for creating Android Spannable. This library wrappers SpannableStringBuilder and add methods to easily decorate the text with multiple spans.

 A music picker library for React Native. Provides access to the system's UI for selecting songs from the phone's music library.
A music picker library for React Native. Provides access to the system's UI for selecting songs from the phone's music library.

Expo Music Picker A music picker library for React Native. Provides access to the system's UI for selecting songs from the phone's music library. Supp

This little project provides Kotlin bindings for the popular tree-sitter library

kotlintree This little project provides Kotlin bindings for the popular tree-sitter library. Currently it only supports the Kotlin JVM target, but Kot

An educational android app that provides services like notes, online videos and visualization calculator to learn and understand deep concepts of DSA.
An educational android app that provides services like notes, online videos and visualization calculator to learn and understand deep concepts of DSA.

Aldo ALDO is a free education app for the young programmers who are desiring to master the concepts of Data Structure and Algorithms. ALDO offers prac

BlueNote-Android - an android app that provides simple notes and answer
BlueNote-Android - an android app that provides simple notes and answer

BlueNote AnswerSheet Blue Note is an android app that provides simple notes and

NetGuard provides simple and advanced ways to block access to the internet
NetGuard provides simple and advanced ways to block access to the internet

NetGuard NetGuard provides simple and advanced ways to block access to the internet - no root required. Applications and addresses can individually be

ImmutablePendingIntent provides mutability safe methods and quick fix
ImmutablePendingIntent provides mutability safe methods and quick fix

ImmutablePendingIntent Overview ImmutablePendingIntent provides methods that create immutability-safe PendingIntent lint to make an error when using m

Releases(1.0.0)
Owner
Quantis
A Quantis visa contribuir com a comunidade open-source fornecendo bibliotecas e softwares
Quantis
Solving all 25 days of the AOC 2021 event here: https://adventofcode.com

advent-of-code-2021-kotlin Welcome to the Advent of Code1 Kotlin project using the Advent of Code Kotlin Template delivered by JetBrains. In this repo

Mofe Ejegi 1 Dec 17, 2021
This project consists in the approach of a bakery business, in which the user can book one or more products (cakes), in addition to having the method of payment in cash (post-shipment) or the method of payment via mobile

This project consists in the approach of a bakery business, in which the user can book one or more products (cakes), in addition to having the method of payment in cash (post-shipment) or the method of payment via mobile

Paul Guillen Acuña 2 Dec 20, 2022
Olalekan Fagbemi 0 Nov 7, 2021
An app that is a one-stop destination for all the CS enthusiasts, providing resources like Information scrapping techniques, best YT channels, courses available free-of-cost, etc. & knowledge about every domain and field that exists on the Internet related to Computer Science along with News, Jobs, and Internships opportunities in these domains along with valuable tips and hacks from mentors for a particular domain.

An app that is a one-stop destination for all the CS enthusiasts, providing resources like Information scrapping techniques, best YT channels, courses available free-of-cost, etc. & knowledge about every domain and field that exists on the Internet related to Computer Science along with News, Jobs, and Internships opportunities in these domains along with valuable tips and hacks from mentors for a particular domain.

CSwala 48 Nov 26, 2022
A curated list of great Android lint custom rules and resources

Awesome Android Lint A curated list of great Android lint custom rules and resources Contents Rules Articles Other Contribute Rules Google Sample Cust

Harold Martin 37 Dec 9, 2022
Allows usage of vCard resources with the Android contacts provider

vcard4android vcard4android is an Android library that brings together VCard and Android. It's a framework for parsing and generating VCard resources

bitfire web engineering 7 Dec 15, 2022
Haven is an app to help people in need find resources.

Haven Haven is an app to help people in need find resources. Haven connects people to resources such as food pantries, homeless shelters, healthcare,

Dev Patel 2 Sep 25, 2022
An app for developers which contains more than 2.4k+ resources , with 1.2k+ free public API documentation

ResourceUp We often spend a lot of time finding good resources to get started with our project right? ResourceUp aims to provide all useful resources

kalp patel 10 Apr 30, 2022
Loco-strings-sync - A custom Gradle Plugin useful to sync loco string resources to local projects

loco-strings-sync A custom Gradle Plugin useful to sync loco string resources to

Jonathan Imperato 1 Feb 14, 2022
A modular and portable open source XMPP client library written in Java for Android and Java (SE) VMs

Smack About Smack is an open-source, highly modular, easy to use, XMPP client library written in Java for Java SE compatible JVMs and Android. Being a

Ignite Realtime 2.3k Dec 28, 2022