Java Calculate Orthodox Easter Date

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;
}
Advertisements

About cmanios

programming
This entry was posted in Android, Java and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s