Java library to figure out when Easter is.
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.
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.
Maven 3 is required to compile this project.
$ git clone https://github.com/Aldaviva/easter4j.git
$ cd easter4j/easter4j-parent
$ mvn install
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>
Easter4J.getEaster(2016);
Fully-qualified types for each module:
java.util.Calendar easter = com.aldaviva.easter4j.Easter4J.getEaster(2016);
org.joda.time.LocalDate easter = com.aldaviva.easter4j.Easter4J.getEaster(2016);
java.time.LocalDate easter = com.aldaviva.easter4j.Easter4J.getEaster(2016);