use of android.icu.util.HebrewCalendar in project j2objc by google.
the class HebrewTest method TestDefaultFieldValues.
/**
* Test handling of ADAR_1.
*/
/*
@Test
public void TestAdar1() {
HebrewCalendar cal = new HebrewCalendar();
cal.clear();
cal.set(Calendar.YEAR, 1903); // leap
cal.set(Calendar.MONTH, HebrewCalendar.ADAR_1);
logln("1903(leap)/ADAR_1 => " +
cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH)+1));
cal.clear();
cal.set(Calendar.YEAR, 1904); // non-leap
cal.set(Calendar.MONTH, HebrewCalendar.ADAR_1);
logln("1904(non-leap)/ADAR_1 => " +
cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH)+1));
}
*/
/**
* With no fields set, the calendar should use default values.
*/
@Test
public void TestDefaultFieldValues() {
try {
HebrewCalendar cal = new HebrewCalendar();
cal.clear();
logln("cal.clear() -> " + cal.getTime());
} catch (MissingResourceException ex) {
warnln("could not load the locale data");
}
}
use of android.icu.util.HebrewCalendar in project j2objc by google.
the class HebrewTest method TestMonthValidation.
// Test case for Ticket#10313. HebrewCalendar requires
// special handling for validating month value, because
// month Adar I is only available in leap years.
@Test
public void TestMonthValidation() {
HebrewCalendar cal = new HebrewCalendar();
cal.setLenient(false);
// 5776 is a leap year and has month Adar I
cal.set(5776, ADAR_1, 1);
try {
/* Date d = */
cal.getTime();
} catch (IllegalArgumentException e) {
errln("Fail: 5776 Adar I 1 is a valid date.");
}
// 5777 is NOT a lear year and does not have month Adar I
cal.set(5777, ADAR_1, 1);
try {
/* Date d = */
cal.getTime();
errln("Fail: IllegalArgumentException should be thrown for input date 5777 Adar I 1.");
} catch (IllegalArgumentException e) {
logln("Info: IllegalArgumentException, because 5777 Adar I 1 is not a valid date.");
}
}
use of android.icu.util.HebrewCalendar in project j2objc by google.
the class HebrewTest method TestTimeFields.
/**
* Problem reported by Armand Bendanan in which setting of the MONTH
* field in a Hebrew calendar causes the time fields to go negative.
*/
@Test
public void TestTimeFields() {
try {
HebrewCalendar calendar = new HebrewCalendar(5761, 0, 11, 12, 28, 15);
calendar.set(Calendar.YEAR, 5717);
calendar.set(Calendar.MONTH, 2);
calendar.set(Calendar.DAY_OF_MONTH, 23);
if (calendar.get(Calendar.HOUR_OF_DAY) != 12) {
errln("Fail: HebrewCalendar HOUR_OF_DAY = " + calendar.get(Calendar.HOUR_OF_DAY));
}
} catch (MissingResourceException ex) {
warnln("Got Exception: " + ex.getMessage());
}
}
use of android.icu.util.HebrewCalendar in project j2objc by google.
the class HebrewTest method TestLimits.
/**
* Test limits of the Hebrew calendar
*/
@Test
public void TestLimits() {
Calendar cal = Calendar.getInstance();
cal.set(2007, Calendar.JANUARY, 1);
HebrewCalendar hebrew = new HebrewCalendar();
doLimitsTest(hebrew, null, cal.getTime());
doTheoreticalLimitsTest(hebrew, true);
}
use of android.icu.util.HebrewCalendar in project j2objc by google.
the class HebrewTest method Test1624.
@Test
public void Test1624() {
HebrewCalendar hc = new HebrewCalendar(5742, HebrewCalendar.AV, 22);
DateFormat df = hc.getDateTimeFormat(DateFormat.FULL, DateFormat.FULL, Locale.getDefault());
String dateString = df.format(hc.getTime());
for (int year = 5600; year < 5800; year++) {
boolean leapYear = HebrewCalendar.isLeapYear(year);
for (int month = HebrewCalendar.TISHRI; month <= HebrewCalendar.ELUL; month++) {
// skip the adar 1 month if year is not a leap year
if (leapYear == false && month == HebrewCalendar.ADAR_1) {
continue;
}
int day = 15;
hc = new HebrewCalendar(year, month, day);
dateString = df.format(hc.getTime());
int dayHC = hc.get(HebrewCalendar.DATE);
int monthHC = hc.get(HebrewCalendar.MONTH);
int yearHC = hc.get(HebrewCalendar.YEAR);
String header = "year:" + year + " isleap:" + leapYear + " " + dateString;
if (dayHC != day) {
errln(header + " ==> day:" + dayHC + " incorrect, should be:" + day);
break;
}
if (monthHC != month) {
errln(header + " ==> month:" + monthHC + " incorrect, should be:" + month);
break;
}
if (yearHC != year) {
errln(header + " ==> year:" + yearHC + " incorrecte, should be:" + year);
break;
}
}
}
}
Aggregations