Java Calculate Orthodox Easter Date

1 minute read

Today I wondered if there is an algorithm to calculate the date of Orthodox Easter. After some searching in the web I found the algorithm and converted it to Java code.

/**
 * @param myear
 *            the year of which we want to get the Orthodox Easter date
 * @return the date of the Orthodox easter of the given year
 */
public Calendar getOrthodoxEaster(int myear) {
	Calendar dof = Calendar.getInstance();

	int r1 = myear % 4;
	int r2 = myear % 7;
	int r3 = myear % 19;
	int r4 = (19 * r3 + 15) % 30;
	int r5 = (2 * r1 + 4 * r2 + 6 * r4 + 6) % 7;
	int mdays = r5 + r4 + 13;

	if (mdays > 39) {
		mdays = mdays - 39;
		dof.set(myear, 4, mdays);
	} else if (mdays > 9) {
		mdays = mdays - 9;
		dof.set(myear, 3, mdays);
	} else {
		mdays = mdays + 22;
		dof.set(myear, 2, mdays);
	}
	return dof;
}

Comments