/** * Returns the date of Easter Sunday for the given year. See the class description for the source * of the algorithm. * * <p>This method supports the AnnualDateRule interface. * * @param year the year to check. * @return the date of Easter Sunday for the given year. */ public SerialDate getDate(int year) { int g = year % 19; int c = year / 100; int h = (c - c / 4 - (8 * c + 13) / 25 + 19 * g + 15) % 30; int i = h - h / 28 * (1 - h / 28 * 29 / (h + 1) * (21 - g) / 11); int j = (year + year / 4 + i + 2 - c + c / 4) % 7; int l = i - j; int month = 3 + (l + 40) / 44; int day = l + 28 - 31 * (month / 4); return SerialDate.createInstance(day, month, year); }
/** Problem 30/360PSA day count. */ public void testDayCount30PSA() { final SerialDate d1 = SerialDate.createInstance(1, MonthConstants.APRIL, 2002); final SerialDate d2 = SerialDate.createInstance(2, MonthConstants.APRIL, 2002); final int count = SerialDateUtilities.dayCount30PSA(d1, d2); assertEquals(1, count); }