public String getEasterSunday ( int year , int days ) { int K = year / 100 ; int M = 15 + ( ( 3 * K + 3 ) / 4 ) - ( ( 8 * K + 13 ) / 25 ) ; int S = 2 - ( ( 3 * K + 3 ) / 4 ) ; int A = year % 19 ; int D = ( 19 * A + M ) % 30 ; int R = ( D / 29 ) + ( ( D / 28 ) - ( D / 29 ) * ( A / 11 ) ) ; int OG = 21 + D - R ; int SZ = 7 - ( year + ( year / 4 ) + S ) % 7 ; int OE = 7 - ( OG - SZ ) % 7 ; int OS = OG + OE ; SimpleDateFormat formatter = new SimpleDateFormat ( "yyyy-MM-dd" ) ; Calendar c = Calendar . getInstance ( ) ; String date ; if ( OS <= 31 ) { date = String . format ( "%04d-03-%02d" , year , OS ) ; } else { date = String . format ( "%04d-04-%02d" , year , ( OS - 31 ) ) ; } try { c . setTime ( formatter . parse ( date ) ) ; c . add ( Calendar . DAY_OF_MONTH , days ) ; date = formatter . format ( c . getTime ( ) ) ; } catch ( ParseException e ) { e . printStackTrace ( ) ; } return date ; }
Get the date of a day relative to Easter Sunday in a given year . Algorithm used is from the Physikalisch - Technische Bundesanstalt Braunschweig PTB .