Skip to content

Instantly share code, notes, and snippets.

@GaetanoPiazzolla
Created April 4, 2021 13:19
Show Gist options
  • Save GaetanoPiazzolla/c3b076efd2cc58d414f71f4baf25711c to your computer and use it in GitHub Desktop.
Save GaetanoPiazzolla/c3b076efd2cc58d414f71f4baf25711c to your computer and use it in GitHub Desktop.
Calculate easter
import java.time.LocalDate;
public class Easter{
public static void main(String []args){
System.out.println(HelloWorld.getEasterOfYear(2021));
}
private static LocalDate getEasterOfYear(int y) {
int a = y % 19;
int b = y / 100;
int c = y % 100;
int d = b / 4;
int e = b % 4;
int g = (8 * b + 13) / 25;
int h = (19 * a + b - d - g + 15) % 30;
int j = c / 4;
int k = c % 4;
int m = (a + 11 * h) / 319;
int r = (2 * e + 2 * j - k - h + m + 32) % 7;
int n = (h - m + r + 90) / 25;
int p = (h - m + r + n + 19) % 32;
return LocalDate.of(y, n, p);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment