use of android.icu.util.EasterHoliday in project j2objc by google.
the class HolidayTest method TestCoverage.
@Test
public void TestCoverage() {
Holiday[] h = { new EasterHoliday("Ram's Easter"), new SimpleHoliday(2, 29, 0, "Leap year", 1900, 2100) };
exerciseHolidays(h, Locale.getDefault());
RangeDateRule rdr = new RangeDateRule();
rdr.add(new SimpleDateRule(7, 10));
Date mbd = getDate(1953, Calendar.JULY, 10);
Date dbd = getDate(1958, Calendar.AUGUST, 15);
Date nbd = getDate(1990, Calendar.DECEMBER, 17);
Date abd = getDate(1992, Calendar.SEPTEMBER, 16);
Date xbd = getDate(1976, Calendar.JULY, 4);
Date ybd = getDate(2003, Calendar.DECEMBER, 8);
rdr.add(new SimpleDateRule(Calendar.JULY, 10, Calendar.MONDAY, false));
rdr.add(dbd, new SimpleDateRule(Calendar.AUGUST, 15, Calendar.WEDNESDAY, true));
rdr.add(xbd, null);
rdr.add(nbd, new SimpleDateRule(Calendar.DECEMBER, 17, Calendar.MONDAY, false));
rdr.add(ybd, null);
logln("first after " + mbd + " is " + rdr.firstAfter(mbd));
logln("first between " + mbd + " and " + dbd + " is " + rdr.firstBetween(mbd, dbd));
logln("first between " + dbd + " and " + nbd + " is " + rdr.firstBetween(dbd, nbd));
logln("first between " + nbd + " and " + abd + " is " + rdr.firstBetween(nbd, abd));
logln("first between " + abd + " and " + xbd + " is " + rdr.firstBetween(abd, xbd));
logln("first between " + abd + " and " + null + " is " + rdr.firstBetween(abd, null));
logln("first between " + xbd + " and " + null + " is " + rdr.firstBetween(xbd, null));
// getRule, setRule
logln("The rule in the holiday: " + h[1].getRule());
exerciseHoliday(h[1], Locale.getDefault());
h[1].setRule(rdr);
logln("Set the new rule to the SimpleHoliday ...");
if (!rdr.equals(h[1].getRule())) {
errln("FAIL: getRule and setRule not matched.");
}
exerciseHoliday(h[1], Locale.getDefault());
}
use of android.icu.util.EasterHoliday in project j2objc by google.
the class HolidayTest method TestEaster.
@Test
public void TestEaster() {
// Verify that Easter is working. Should be April 20, 2014
final Holiday h = new EasterHoliday("Easter Sunday");
final Date beginApril = getDate(2014, Calendar.APRIL, 1);
final Date endApril = getDate(2014, Calendar.APRIL, 30);
final Date expect = getDate(2014, Calendar.APRIL, 20);
final Date actual = h.firstBetween(beginApril, endApril);
if (actual == null) {
errln("Error: Easter 2014 should be on " + expect + " but got null.");
} else {
Calendar c = Calendar.getInstance(TimeZone.GMT_ZONE, Locale.US);
c.setTime(actual);
assertEquals("Easter's year: ", 2014, c.get(Calendar.YEAR));
assertEquals("Easter's month: ", Calendar.APRIL, c.get(Calendar.MONTH));
assertEquals("Easter's date: ", 20, c.get(Calendar.DATE));
}
}
Aggregations