Java Easter getEasterDay(int year)

Here you can find the source of getEasterDay(int year)

Description

get Easter Day

License

Open Source License

Declaration

private static Date getEasterDay(int year) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Calendar;
import java.util.Date;

public class Main {

    private static Date getEasterDay(int year) {
        int a = year % 19;
        int b = year / 100;
        int c = year % 100;
        int d = b / 4;
        int e = b % 4;
        int f = (b + 8) / 25;
        int g = (b - f + 1) / 3;
        int h = ((19 * a) + b - d - g + 15) % 30;
        int i = c / 4;
        int k = c % 4;
        int l = (32 + (2 * e) + (2 * i) - h - k) % 7;
        int m = (a + (11 * h) + (22 * l)) / 451;
        int n = (h + l - (7 * m) + 114) / 31; // This is the month number.
        int p = (h + l - (7 * m) + 114) % 31; // This is the date minus one.

        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.YEAR, year);
        cal.set(Calendar.MONTH, n - 1);
        cal.set(Calendar.DATE, p + 1);

        return cal.getTime();
    }/*from  w  ww.  j ava 2  s.c o m*/
}

Related

  1. calculateEasterDay(int year)
  2. getSundayOfEaster(final int year)