Skip to content

Instantly share code, notes, and snippets.

@flogvit
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flogvit/32639d4745c0f8b69df8 to your computer and use it in GitHub Desktop.
Save flogvit/32639d4745c0f8b69df8 to your computer and use it in GitHub Desktop.
/**
* Small class for getting Easter Sunday at a specific year
*/
public class Easter {
public static Calendar get(int year) {
int y = year;
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;
Calendar cal = Calendar.getInstance();
cal.clear();
cal.set(y, n, p);
return cal;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment