Search in sources :

Example 6 with IslamicCalendar

use of android.icu.util.IslamicCalendar in project j2objc by google.

the class IslamicTest method TestIslamicTabularDates.

@Test
public void TestIslamicTabularDates() {
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
    Date date = null;
    try {
        date = formatter.parse("1975-05-06");
    } catch (Exception e) {
        errln("unable to parse test date string - errMsg:" + e.getLocalizedMessage());
    }
    IslamicCalendar is_cal = new IslamicCalendar();
    is_cal.setCalculationType(CalculationType.ISLAMIC_CIVIL);
    is_cal.setTime(date);
    IslamicCalendar is_cal2 = new IslamicCalendar();
    is_cal2.setCalculationType(CalculationType.ISLAMIC_TBLA);
    is_cal2.setTime(date);
    int is_month = is_cal.get(Calendar.MONTH);
    int is_month2 = is_cal2.get(Calendar.MONTH);
    int is_year = is_cal.get(Calendar.YEAR);
    int is_year2 = is_cal2.get(Calendar.YEAR);
    if ((is_month != is_month2) || (is_year != is_year2))
        errln("unexpected difference between islamic and tbla month " + is_month + " : " + is_month2 + " and/or year " + is_year + " : " + is_year2);
    int is_day = is_cal.get(Calendar.DAY_OF_MONTH);
    int is_day2 = is_cal2.get(Calendar.DAY_OF_MONTH);
    if (is_day2 - is_day != 1)
        errln("unexpected difference between civil and tbla: " + is_day2 + " : " + is_day);
}
Also used : SimpleDateFormat(android.icu.text.SimpleDateFormat) Date(java.util.Date) IOException(java.io.IOException) IslamicCalendar(android.icu.util.IslamicCalendar) Test(org.junit.Test)

Example 7 with IslamicCalendar

use of android.icu.util.IslamicCalendar in project j2objc by google.

the class IslamicTest method TestBasic.

@Test
public void TestBasic() {
    IslamicCalendar cal = newCivil();
    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));
}
Also used : IslamicCalendar(android.icu.util.IslamicCalendar) Test(org.junit.Test)

Example 8 with IslamicCalendar

use of android.icu.util.IslamicCalendar in project j2objc by google.

the class IslamicTest method newIslamicUmalqura.

private static IslamicCalendar newIslamicUmalqura() {
    IslamicCalendar civilCalendar = new IslamicCalendar();
    civilCalendar.setCalculationType(CalculationType.ISLAMIC_UMALQURA);
    return civilCalendar;
}
Also used : IslamicCalendar(android.icu.util.IslamicCalendar)

Example 9 with IslamicCalendar

use of android.icu.util.IslamicCalendar in project j2objc by google.

the class IslamicTest method newCivil.

private static IslamicCalendar newCivil() {
    IslamicCalendar civilCalendar = new IslamicCalendar();
    civilCalendar.setCalculationType(CalculationType.ISLAMIC_CIVIL);
    return civilCalendar;
}
Also used : IslamicCalendar(android.icu.util.IslamicCalendar)

Example 10 with IslamicCalendar

use of android.icu.util.IslamicCalendar in project j2objc by google.

the class IslamicTest method TestRoll.

@Test
public void TestRoll() {
    int[][] tests = new int[][] { // non-leap years
    { 0001, QIDAH, 2, MONTH, 1, 0001, HIJJAH, 2 }, { 0001, QIDAH, 2, MONTH, 2, 0001, MUHARRAM, 2 }, { 0001, QIDAH, 2, MONTH, -1, 0001, SHAWWAL, 2 }, { 0001, MUHARRAM, 2, MONTH, 12, 0001, MUHARRAM, 2 }, { 0001, MUHARRAM, 2, MONTH, 13, 0001, SAFAR, 2 }, // 29-day month
    { 0001, HIJJAH, 1, DATE, 30, 0001, HIJJAH, 2 }, // 30-day month
    { 0002, HIJJAH, 1, DATE, 31, 0002, HIJJAH, 2 }, // Try some rolls that require other fields to be adjusted
    { 0001, MUHARRAM, 30, MONTH, 1, 0001, SAFAR, 29 }, { 0002, HIJJAH, 30, YEAR, -1, 0001, HIJJAH, 29 } };
    IslamicCalendar cal = newCivil();
    doRollAdd(ROLL, cal, tests);
    cal = newIslamicUmalqura();
    doRollAdd(ROLL, cal, tests);
}
Also used : IslamicCalendar(android.icu.util.IslamicCalendar) Test(org.junit.Test)

Aggregations

IslamicCalendar (android.icu.util.IslamicCalendar)17 Test (org.junit.Test)14 GregorianCalendar (android.icu.util.GregorianCalendar)7 ULocale (android.icu.util.ULocale)7 SimpleDateFormat (android.icu.text.SimpleDateFormat)6 Calendar (android.icu.util.Calendar)5 JapaneseCalendar (android.icu.util.JapaneseCalendar)4 Date (java.util.Date)4 DateFormat (android.icu.text.DateFormat)3 BuddhistCalendar (android.icu.util.BuddhistCalendar)3 TimeZone (android.icu.util.TimeZone)3 IOException (java.io.IOException)3 GlobalizationPreferences (android.icu.util.GlobalizationPreferences)2 Locale (java.util.Locale)2 ChineseDateFormat (android.icu.text.ChineseDateFormat)1 ChineseCalendar (android.icu.util.ChineseCalendar)1 HebrewCalendar (android.icu.util.HebrewCalendar)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ObjectInputStream (java.io.ObjectInputStream)1