Skip to content

Aldaviva/easter4j

Repository files navigation

easter4j

Java library to figure out when Easter is.

Build Status

Algorithm

Thanks to history, religion, politics, and astronomy, figuring out the date of Easter is a preposterously complicated procedure called Computus.

There are many implementations of Computus algorithms. This library uses Ian Taylor's Computus 1 algorithm because it's fast.

Components

There are several ways to represent a date in Java, and this library provides several modules so you can choose the one you want.

  • easter4j-calendar: uses the JDK1.1 Calendar class (highly compatible, most annoying API)
  • easter4j-jodatime: uses the Joda-Time library (extra transitive dependency, requires Java 5, great API)
  • easter4j-jdk8: uses the JDK8 LocalDate class (requires Java ≥ 8, great API)

Pick one and declare it as a dependency.

Building

Maven 3 is required to compile this project.

$ git clone https://github.com/Aldaviva/easter4j.git
$ cd easter4j/easter4j-parent
$ mvn install

Installing

Add a dependency to your project's pom.xml:

<project>
    <dependencies>
        <dependency>
            <groupId>com.aldaviva.easter4j</groupId>
            <!-- Pick the artifact you want, see Components above -->
            <artifactId>easter4j-calendar</artifactId>
            <!-- <artifactId>easter4j-jodatime</artifactId> --> 
            <!-- <artifactId>easter4j-jdk8</artifactId> -->
            <version>1.0.0</version>
        </dependency>
    </dependencies>
</project>

Usage

Easter4J.getEaster(2016);

Fully-qualified types for each module:

JDK1.1 Calendar
java.util.Calendar easter = com.aldaviva.easter4j.Easter4J.getEaster(2016);
Joda-Time
org.joda.time.LocalDate easter = com.aldaviva.easter4j.Easter4J.getEaster(2016);
JDK8 LocalDate
java.time.LocalDate easter = com.aldaviva.easter4j.Easter4J.getEaster(2016);

About

Java library to figure out when Easter is.

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Languages