use of android.icu.util.CopticCalendar in project j2objc by google.
the class CopticTest method TestBasic.
@Test
public void TestBasic() {
CopticCalendar cal = new CopticCalendar();
cal.clear();
cal.set(1000, 0, 30);
logln("1000/0/30-> " + cal.get(YEAR) + "/" + cal.get(MONTH) + "/" + cal.get(DATE));
cal.clear();
cal.set(1, 0, 30);
logln("1/0/30 -> " + cal.get(YEAR) + "/" + cal.get(MONTH) + "/" + cal.get(DATE));
}
use of android.icu.util.CopticCalendar in project j2objc by google.
the class CopticTest method TestYear.
@Test
public void TestYear() {
// Gregorian Calendar
Calendar gCal = new GregorianCalendar();
Date gToday = gCal.getTime();
gCal.add(GregorianCalendar.MONTH, 2);
Date gFuture = gCal.getTime();
DateFormat gDF = DateFormat.getDateInstance(gCal, DateFormat.FULL);
logln("gregorian calendar: " + gDF.format(gToday) + " + 2 months = " + gDF.format(gFuture));
// Coptic Calendar
CopticCalendar cCal = new CopticCalendar();
Date cToday = cCal.getTime();
cCal.add(CopticCalendar.MONTH, 2);
Date cFuture = cCal.getTime();
DateFormat cDF = DateFormat.getDateInstance(cCal, DateFormat.FULL);
logln("coptic calendar: " + cDF.format(cToday) + " + 2 months = " + cDF.format(cFuture));
// EthiopicCalendar
EthiopicCalendar eCal = new EthiopicCalendar();
Date eToday = eCal.getTime();
// add 2 months
eCal.add(EthiopicCalendar.MONTH, 2);
eCal.setAmeteAlemEra(false);
Date eFuture = eCal.getTime();
DateFormat eDF = DateFormat.getDateInstance(eCal, DateFormat.FULL);
logln("ethiopic calendar: " + eDF.format(eToday) + " + 2 months = " + eDF.format(eFuture));
}
use of android.icu.util.CopticCalendar in project j2objc by google.
the class CopticTest method TestLimits.
/**
* Test limits of the Coptic calendar
*/
@Test
public void TestLimits() {
Calendar cal = Calendar.getInstance();
cal.set(2007, Calendar.JANUARY, 1);
CopticCalendar coptic = new CopticCalendar();
doLimitsTest(coptic, null, cal.getTime());
doTheoreticalLimitsTest(coptic, true);
}
use of android.icu.util.CopticCalendar in project j2objc by google.
the class CopticTest method Test6379.
/**
* Test for track ticket 6379 - proper reporting of
* maximum month lengths
*/
@Test
public void Test6379() {
CopticCalendar copticCal = new CopticCalendar();
copticCal.clear();
for (int year = 1725; year < 1735; year++) {
// Coptic 1725-01-01 = Gregorian 2008-09-11
boolean isLeap = ((year % 4) == 3);
copticCal.set(Calendar.YEAR, year);
int maxMonth = copticCal.getActualMaximum(Calendar.MONTH);
for (int month = 0; month <= maxMonth; month++) {
copticCal.set(Calendar.MONTH, month);
int maxDayOfMonth = copticCal.getActualMaximum(Calendar.DAY_OF_MONTH);
int expected = (month != maxMonth) ? 30 : (isLeap ? 6 : 5);
if (maxDayOfMonth != expected) {
errln("FAIL: Expected maximum " + expected + " days for month #" + (month + 1) + " - returned:" + maxDayOfMonth);
}
}
}
}
use of android.icu.util.CopticCalendar in project j2objc by google.
the class CopticTest method TestEraStart.
// basic check to see that we print out eras ok
// eventually should modify to use locale strings and formatter appropriate to coptic calendar
@Test
public void TestEraStart() {
SimpleDateFormat fmt = new SimpleDateFormat("EEE MMM dd, yyyy GG");
SimpleDateFormat copticFmt = new SimpleDateFormat("EEE MMM dd, yyyy GG");
copticFmt.setCalendar(new CopticCalendar());
CopticCalendar cal = new CopticCalendar(1, 0, 1);
assertEquals("Coptic Date", "Fri Jan 01, 0001 AD", copticFmt.format(cal));
assertEquals("Gregorian Date", "Fri Aug 29, 0284 AD", fmt.format(cal.getTime()));
cal.set(Calendar.ERA, 0);
cal.set(Calendar.YEAR, 1);
assertEquals("Coptic Date", "Thu Jan 01, 0001 BC", copticFmt.format(cal));
assertEquals("Gregorian Date", "Thu Aug 30, 0283 AD", fmt.format(cal.getTime()));
}
Aggregations