Java Code Examples for android.icu.util.Calendar#getInstance()

The following examples show how to use android.icu.util.Calendar#getInstance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DangiTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
/**
 * Test minimum and maximum functions.
 */
@Test
public void TestLimits() {
    // The number of days and the start date can be adjusted
    // arbitrarily to either speed up the test or make it more
    // thorough, but try to test at least a full year, preferably a
    // full non-leap and a full leap year.

    // Final parameter is either number of days, if > 0, or test
    // duration in seconds, if < 0.
    Calendar tempcal = Calendar.getInstance();
    tempcal.clear();
    tempcal.set(1989, Calendar.NOVEMBER, 1);
    Calendar dangi = Calendar.getInstance(new ULocale("ko_KR@calendar=dangi"));
    doLimitsTest(dangi, null, tempcal.getTime());
    doTheoreticalLimitsTest(dangi, true);
}
 
Example 2
Source File: CalendarRegressionTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
/**
 * Prove that GregorianCalendar is proleptic (it used to cut off at 45 BC,
 * and not have leap years before then).
 */
@Test
public void Test4125892() {
    GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();
    //DateFormat fmt = new SimpleDateFormat("MMMM d, yyyy G");
    //fmt = null;
    cal.clear();
    cal.set(Calendar.ERA, GregorianCalendar.BC);
    cal.set(Calendar.YEAR, 81); // 81 BC is a leap year (proleptically)
    cal.set(Calendar.MONTH, Calendar.FEBRUARY);
    cal.set(Calendar.DATE, 28);
    cal.add(Calendar.DATE, 1);
    if (cal.get(Calendar.DATE) != 29 ||
        !cal.isLeapYear(-80)) // -80 == 81 BC
        errln("Calendar not proleptic");
}
 
Example 3
Source File: DangiTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
/**
 * Make sure no Gregorian dates map to Chinese 1-based day of
 * month zero.  This was a problem with some of the astronomical
 * new moon determinations.
 */
@Test
public void TestZeroDOM() {
    Calendar cal = Calendar.getInstance(new ULocale("ko_KR@calendar=dangi"));
    GregorianCalendar greg = new GregorianCalendar(1989, Calendar.SEPTEMBER, 1);
    logln("Start: " + greg.getTime());
    for (int i=0; i<1000; ++i) {
        cal.setTimeInMillis(greg.getTimeInMillis());
        if (cal.get(Calendar.DAY_OF_MONTH) == 0) {
            errln("Fail: " + greg.getTime() + " -> " +
                  cal.get(Calendar.YEAR) + "/" +
                  cal.get(Calendar.MONTH) +
                  (cal.get(Calendar.IS_LEAP_MONTH)==1?"(leap)":"") +
                  "/" + cal.get(Calendar.DAY_OF_MONTH));
        }
        greg.add(Calendar.DAY_OF_YEAR, 1);
    }
    logln("End: " + greg.getTime());
}
 
Example 4
Source File: DatePicker.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public final void autofill(AutofillValue value) {
    if (value == null || !value.isDate()) {
        Log.w(LOG_TAG, value + " could not be autofilled into " + this);
        return;
    }

    final long time = value.getDateValue();

    final Calendar cal = Calendar.getInstance(mCurrentLocale);
    cal.setTimeInMillis(time);
    updateDate(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH),
            cal.get(Calendar.DAY_OF_MONTH));

    // Must set mAutofilledValue *after* calling subclass method to make sure the value
    // returned by getAutofillValue() matches it.
    mAutofilledValue = time;
}
 
Example 5
Source File: IndianTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * Problem reported by Bruno Haible <[email protected]>
 *  -- see ticket 8419 -- http://bugs.icu-project.org/trac/ticket/8419
 * Problem with months out of range 0-11
 */
@Test
public void TestYearEdge() {
    // Display dates in ISO 8601 format.
    DateFormat fmt = new SimpleDateFormat("YYYY-MM-dd", ULocale.US);

    // Instantiate an Indian calendar.
    ULocale locale = ULocale.US.setKeywordValue("calendar", "indian");
    Calendar cal = Calendar.getInstance(locale);

    // Try add() repeatedly.
    cal.setTimeInMillis(1295568000000L);
    if (!fmt.format(cal.getTime()).equals("2011-01-20")){
        errln("Incorrect calendar value for year edge test");
    }
    cal.add(Calendar.MONTH, 1);
    if (!fmt.format(cal.getTime()).equals("2011-02-19")){
        errln("Incorrect calendar value for year edge test");
    }
    cal.add(Calendar.MONTH, 1);
    if (!fmt.format(cal.getTime()).equals("2011-03-21")){
        errln("Incorrect calendar value for year edge test");
    }
    cal.add(Calendar.MONTH, 1);
    if (!fmt.format(cal.getTime()).equals("2011-04-20")){
        errln("Incorrect calendar value for year edge test");
    }
}
 
Example 6
Source File: DateFormat.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a DateFormat with the given time and/or date style in the given
 * locale.
 * @param dateStyle a value from 0 to 3 indicating the time format,
 * or -1 to indicate no date
 * @param timeStyle a value from 0 to 3 indicating the time format,
 * or -1 to indicate no time
 * @param loc the locale for the format
 * @param cal the calendar to be used, or null
 */
private static DateFormat get(int dateStyle, int timeStyle, ULocale loc, Calendar cal) {
    if((timeStyle != DateFormat.NONE && (timeStyle & RELATIVE)>0) ||
       (dateStyle != DateFormat.NONE && (dateStyle & RELATIVE)>0)) {
        RelativeDateFormat r = new RelativeDateFormat(timeStyle, dateStyle /* offset? */, loc, cal);
        return r;
    }

    if (timeStyle < DateFormat.NONE || timeStyle > DateFormat.SHORT) {
        throw new IllegalArgumentException("Illegal time style " + timeStyle);
    }
    if (dateStyle < DateFormat.NONE || dateStyle > DateFormat.SHORT) {
        throw new IllegalArgumentException("Illegal date style " + dateStyle);
    }

    if (cal == null) {
        cal = Calendar.getInstance(loc);
    }

    try {
        DateFormat result = cal.getDateTimeFormat(dateStyle, timeStyle, loc);
        result.setLocale(cal.getLocale(ULocale.VALID_LOCALE),
             cal.getLocale(ULocale.ACTUAL_LOCALE));
        return result;
    } catch (MissingResourceException e) {
        ///CLOVER:OFF
        // coverage requires separate run with no data, so skip
        return new SimpleDateFormat("M/d/yy h:mm a");
        ///CLOVER:ON
    }
}
 
Example 7
Source File: SimpleDateFormat.java    From j2objc with Apache License 2.0 5 votes vote down vote up
private static synchronized String getDefaultPattern() {
    ULocale defaultLocale = ULocale.getDefault(Category.FORMAT);
    if (!defaultLocale.equals(cachedDefaultLocale)) {
        cachedDefaultLocale = defaultLocale;
        Calendar cal = Calendar.getInstance(cachedDefaultLocale);

        try {
            // Load the calendar data directly.
            ICUResourceBundle rb = (ICUResourceBundle) UResourceBundle.getBundleInstance(
                    ICUData.ICU_BASE_NAME, cachedDefaultLocale);
            String resourcePath = "calendar/" + cal.getType() + "/DateTimePatterns";
            ICUResourceBundle patternsRb= rb.findWithFallback(resourcePath);

            if (patternsRb == null) {
                patternsRb = rb.findWithFallback("calendar/gregorian/DateTimePatterns");
            }
            if (patternsRb == null || patternsRb.getSize() < 9) {
                cachedDefaultPattern = FALLBACKPATTERN;
            } else {
                int defaultIndex = 8;
                if (patternsRb.getSize() >= 13) {
                    defaultIndex += (SHORT + 1);
                }
                String basePattern = patternsRb.getString(defaultIndex);

                cachedDefaultPattern = SimpleFormatterImpl.formatRawPattern(
                        basePattern, 2, 2,
                        patternsRb.getString(SHORT), patternsRb.getString(SHORT + 4));
            }
        } catch (MissingResourceException e) {
            cachedDefaultPattern = FALLBACKPATTERN;
        }
    }
    return cachedDefaultPattern;
}
 
Example 8
Source File: DateFormatRegressionTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * @bug 4104136
 */
@Test
public void Test4104136() {
    SimpleDateFormat sdf = new SimpleDateFormat();
    String pattern = "'time' hh:mm";
    sdf.applyPattern(pattern);
    logln("pattern: \"" + pattern + "\"");
    String strings[] = {"time 10:30", "time 10:x", "time 10x"};
    ParsePosition ppos[] = {new ParsePosition(10), new ParsePosition(0), new ParsePosition(0)};
    Calendar cal = Calendar.getInstance();
    cal.clear();
    cal.set(1970, Calendar.JANUARY, 1, 10, 30);
    Date dates[] = {cal.getTime(), new Date(-1), new Date(-1)};
    for (int i = 0; i < 3; i++) {
        String text = strings[i];
        ParsePosition finish = ppos[i];
        Date exp = dates[i];
        ParsePosition pos = new ParsePosition(0);
        Date d = sdf.parse(text, pos);
        logln(" text: \"" + text + "\"");
        logln(" index: %d" + pos.getIndex());
        logln(" result: " + d);
        if (pos.getIndex() != finish.getIndex())
            errln("Fail: Expected pos " + finish.getIndex());
        if (!((d == null && exp.equals(new Date(-1))) || (d.equals(exp))))
            errln( "Fail: Expected result " + exp);
    }
}
 
Example 9
Source File: DayPickerView.java    From DateTimePicker with Apache License 2.0 5 votes vote down vote up
private Calendar getTempCalendarForTime(long timeInMillis) {
    if (mTempCalendar == null) {
        mTempCalendar = Calendar.getInstance();
    }
    mTempCalendar.setTimeInMillis(timeInMillis);
    return mTempCalendar;
}
 
Example 10
Source File: DataDrivenCalendarTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
private void testConvert(TestDataModule.TestData testData, DataMap settings, boolean forward) {
        Calendar toCalendar= null;
        // build to calendar
        String testSetting = settings.getString("ToCalendar");
        ULocale loc = new ULocale(testSetting);
        toCalendar = Calendar.getInstance(loc);
        CalendarFieldsSet fromSet = new CalendarFieldsSet(), toSet = new CalendarFieldsSet();
//        DateFormat fmt = new SimpleDateFormat("EEE MMM dd yyyy / YYYY'-W'ww-ee");
        // Start the processing
        int n = 0;
        for (Iterator iter = testData.getDataIterator(); iter.hasNext();) {
            ++n;
            DataMap currentCase = (DataMap) iter.next();

            String caseString = "["+testData.getName()+"#"+n+" "+"]";
            String locale = testSetting = currentCase.getString("locale");
            ULocale fromLoc = new ULocale(testSetting);
            Calendar fromCalendar = Calendar.getInstance(fromLoc);

            fromSet.clear();
            toSet.clear();

            String from = currentCase.getString("from");
            fromSet.parseFrom(from);
            String to = currentCase.getString("to");
            toSet.parseFrom(to, fromSet);

            // now, do it.
            if (forward) {
                logln(caseString +" "+locale+"/"+from+" >>> "+loc+"/"
                        +to);
                testConvert(caseString, fromSet, fromCalendar, toSet, toCalendar, forward);
            } else {
                logln(caseString +" "+locale+"/"+from+" <<< "+loc+"/"
                        +to);
                testConvert(caseString, toSet, toCalendar, fromSet, fromCalendar, forward);
            }
        }
    }
 
Example 11
Source File: TimeZoneRegressionTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
@Test
public void Test4109314() {
    GregorianCalendar testCal = (GregorianCalendar)Calendar.getInstance();
    TimeZone PST = TimeZone.getTimeZone("PST");
    java.util.Calendar tempcal = java.util.Calendar.getInstance();
    tempcal.clear();
    tempcal.set(1998,Calendar.APRIL,4,22,0);
    Date d1 = tempcal.getTime();
    tempcal.set(1998,Calendar.APRIL,5,6,0);
    Date d2 = tempcal.getTime();
    tempcal.set(1998,Calendar.OCTOBER,24,22,0);
    Date d3 = tempcal.getTime();
    tempcal.set(1998,Calendar.OCTOBER,25,6,0);
    Date d4 = tempcal.getTime();
    Object[] testData = {
        PST, d1, d2,
        PST, d3, d4,
    };
    boolean pass=true;
    for (int i=0; i<testData.length; i+=3) {
        testCal.setTimeZone((TimeZone) testData[i]);
        long t = ((Date)testData[i+1]).getTime();
        Date end = (Date) testData[i+2];
        while (t < end.getTime()) {
            testCal.setTime(new Date(t));
            if (!checkCalendar314(testCal, (TimeZone) testData[i]))
                pass = false;
            t += 60*60*1000L;
        }
    }
    if (!pass) errln("Fail: TZ API inconsistent");
}
 
Example 12
Source File: DateFormatRegressionTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * j32 {JDK Bug 4210209 4209272}
 * DateFormat cannot parse Feb 29 2000 when setLenient(false)
 */
@Test
public void Test4210209() {

    String pattern = "MMM d, yyyy";
    DateFormat fmt = new SimpleDateFormat(pattern, Locale.US);
    DateFormat disp = new SimpleDateFormat("MMM dd yyyy GG", Locale.US);

    Calendar calx = fmt.getCalendar();
    calx.setLenient(false);
    Calendar calendar = Calendar.getInstance();
    calendar.clear();
    calendar.set(2000, Calendar.FEBRUARY, 29);
    Date d = calendar.getTime();
    String s = fmt.format(d);
    logln(disp.format(d) + " f> " + pattern + " => \"" + s + "\"");
    ParsePosition pos = new ParsePosition(0);
    d = fmt.parse(s, pos);
    logln("\"" + s + "\" p> " + pattern + " => " +
          (d!=null?disp.format(d):"null"));
    logln("Parse pos = " + pos.getIndex() + ", error pos = " + pos.getErrorIndex());
    if (pos.getErrorIndex() != -1) {
        errln("FAIL: Error index should be -1");
    }

    // The underlying bug is in GregorianCalendar.  If the following lines
    // succeed, the bug is fixed.  If the bug isn't fixed, they will throw
    // an exception.
    GregorianCalendar cal = new GregorianCalendar();
    cal.clear();
    cal.setLenient(false);
    cal.set(2000, Calendar.FEBRUARY, 29); // This should work!
    d = cal.getTime();
    logln("Attempt to set Calendar to Feb 29 2000: " + disp.format(d));
}
 
Example 13
Source File: CalendarRegressionTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * Check isLeapYear for BC years.
 */
@Test
public void Test4125881() {
    GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();
    DateFormat fmt = new SimpleDateFormat("MMMM d, yyyy G");
    cal.clear();
    for (int y=-20; y<=10; ++y) {
        cal.set(Calendar.ERA, y < 1 ? GregorianCalendar.BC : GregorianCalendar.AD);
        cal.set(Calendar.YEAR, y < 1 ? 1 - y : y);
        logln(y + " = " + fmt.format(cal.getTime()) + " " +
                           cal.isLeapYear(y));
        if (cal.isLeapYear(y) != ((y+40)%4 == 0))
            errln("Leap years broken");
    }
}
 
Example 14
Source File: TimeZoneFormatTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
public void TestInheritedFormat() {
    TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
    Calendar cal = Calendar.getInstance(tz);
    cal.setTimeInMillis(1459187377690L); // Mar 28, 2016

    StringBuffer sb = new StringBuffer();
    FieldPosition fp = new FieldPosition(DateFormat.Field.TIME_ZONE);

    TimeZoneFormat fmt = TimeZoneFormat.getInstance(ULocale.ENGLISH);

    // Test formatting a non-timezone related object
    try {
        fmt.format(new Object(), sb, fp);
        errln("ERROR: format non-timezone related object failed");
    } catch (IllegalArgumentException e) { /* Expected */ }

    // Test formatting a TimeZone object
    sb = new StringBuffer();
    fmt.format(tz, sb, fp);
    // When formatting a TimeZone object the formatter uses the current date.
    String fmtOutput = tz.inDaylightTime(new Date()) ? "GMT-07:00" : "GMT-08:00";
    if (!sb.toString().equals(fmtOutput)) {
        errln("ERROR: format TimerZone object failed. Expected: " + fmtOutput + ", actual: " + sb);
    }

    // Test formatting a Calendar object
    sb = new StringBuffer();
    fmt.format(cal, sb, fp);
    if (!sb.toString().equals("GMT-07:00")) {
        errln("ERROR: format Calendar object failed. Expected: GMT-07:00, actual: " + sb);
    }
}
 
Example 15
Source File: DatePickerSpinnerDelegate.java    From DateTimePicker with Apache License 2.0 5 votes vote down vote up
/**
 * Gets a calendar for locale bootstrapped with the value of a given calendar.
 *
 * @param oldCalendar The old calendar.
 * @param locale      The locale.
 */
private Calendar getCalendarForLocale(Calendar oldCalendar, Locale locale) {
    if (oldCalendar == null) {
        return Calendar.getInstance(locale);
    } else {
        final long currentTimeMillis = oldCalendar.getTimeInMillis();
        Calendar newCalendar = Calendar.getInstance(locale);
        newCalendar.setTimeInMillis(currentTimeMillis);
        return newCalendar;
    }
}
 
Example 16
Source File: EthiopicTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * Test limits of the Coptic calendar
 */
@Test
public void TestLimits() {
    Calendar cal = Calendar.getInstance();
    cal.set(2007, Calendar.JANUARY, 1);
    EthiopicCalendar ethiopic = new EthiopicCalendar();
    doLimitsTest(ethiopic, null, cal.getTime());
    doTheoreticalLimitsTest(ethiopic, true);
}
 
Example 17
Source File: CalendarRegressionTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * Make sure maximum for HOUR field is 11, not 12.
 */
@Test
public void Test4118384() {
    Calendar cal = Calendar.getInstance();
    if (cal.getMaximum(Calendar.HOUR) != 11 ||
        cal.getLeastMaximum(Calendar.HOUR) != 11 ||
        cal.getActualMaximum(Calendar.HOUR) != 11)
        errln("Fail: maximum of HOUR field should be 11");
}
 
Example 18
Source File: CalendarRegressionTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
@Test
public void TestT5555() throws Exception
{
    Calendar cal = Calendar.getInstance();
    
    // Set date to Wednesday, February 21, 2007
    cal.set(2007, Calendar.FEBRUARY, 21);

    try {
        // Advance month by three years
        cal.add(Calendar.MONTH, 36);
        
        // Move to last Wednesday of month.
        cal.set(Calendar.DAY_OF_WEEK_IN_MONTH, -1);
        
        cal.getTime();
    } catch (Exception e) {
        errln("Got an exception calling getTime().");
    }
    
    int yy, mm, dd, ee;
    
    yy = cal.get(Calendar.YEAR);
    mm = cal.get(Calendar.MONTH);
    dd = cal.get(Calendar.DATE);
    ee = cal.get(Calendar.DAY_OF_WEEK_IN_MONTH);
    
    if (yy != 2010 || mm != Calendar.FEBRUARY || dd != 24 || ee != Calendar.WEDNESDAY) {
        errln("Got date " + yy + "/" + (mm + 1) + "/" + dd + ", expected 2010/2/24");
    }
}
 
Example 19
Source File: DateFormatRegressionTest.java    From j2objc with Apache License 2.0 4 votes vote down vote up
/**
 * @bug 4065240
 */
@Test
public void Test4065240() {
    Date curDate;
    DateFormat shortdate, fulldate;
    String strShortDate, strFullDate;
    Locale saveLocale = Locale.getDefault();
    TimeZone saveZone = TimeZone.getDefault();

    try {
        Locale curLocale = new Locale("de", "DE");
        Locale.setDefault(curLocale);
        // {sfb} adoptDefault instead of setDefault
        //TimeZone.setDefault(TimeZone.createTimeZone("EST"));
        TimeZone.setDefault(TimeZone.getTimeZone("EST"));
        Calendar cal = Calendar.getInstance();
        cal.clear();
        cal.set(98 + 1900, 0, 1);
        curDate = cal.getTime();
        shortdate = DateFormat.getDateInstance(DateFormat.SHORT);
        fulldate = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG);
        strShortDate = "The current date (short form) is ";
        String temp;
        temp = shortdate.format(curDate);
        strShortDate += temp;
        strFullDate = "The current date (long form) is ";
        String temp2 = fulldate.format(curDate);
        strFullDate += temp2;

        logln(strShortDate);
        logln(strFullDate);

        // {sfb} What to do with resource bundle stuff?????

        // Check to see if the resource is present; if not, we can't test
        //ResourceBundle bundle = //The variable is never used
        //    ICULocaleData.getBundle("DateFormatZoneData", curLocale); 

        // {sfb} API change to ResourceBundle -- add getLocale()
        /*if (bundle.getLocale().getLanguage().equals("de")) {
            // UPDATE THIS AS ZONE NAME RESOURCE FOR <EST> in de_DE is updated
            if (!strFullDate.endsWith("GMT-05:00"))
                errln("Fail: Want GMT-05:00");
        } else {
            logln("*** TEST COULD NOT BE COMPLETED BECAUSE DateFormatZoneData ***");
            logln("*** FOR LOCALE de OR de_DE IS MISSING ***");
        }*/
    } catch (Exception e) {
        logln(e.getMessage());
    } finally {
        Locale.setDefault(saveLocale);
        TimeZone.setDefault(saveZone);
    }

}
 
Example 20
Source File: IBMCalendarTest.java    From j2objc with Apache License 2.0 4 votes vote down vote up
@Test
public void TestRepeatedWallTime() {
    final Object[][] TESTDATA = {
        // Time zone            Input wall time                     WALLTIME_LAST in GMT                WALLTIME_FIRST in GMT
        {"America/New_York",    new CalFields(2011,11,6,0,59,59),   new CalFields(2011,11,6,4,59,59),   new CalFields(2011,11,6,4,59,59)},
        {"America/New_York",    new CalFields(2011,11,6,1,0,0),     new CalFields(2011,11,6,6,0,0),     new CalFields(2011,11,6,5,0,0)},
        {"America/New_York",    new CalFields(2011,11,6,1,0,1),     new CalFields(2011,11,6,6,0,1),     new CalFields(2011,11,6,5,0,1)},
        {"America/New_York",    new CalFields(2011,11,6,1,30,0),    new CalFields(2011,11,6,6,30,0),    new CalFields(2011,11,6,5,30,0)},
        {"America/New_York",    new CalFields(2011,11,6,1,59,59),   new CalFields(2011,11,6,6,59,59),   new CalFields(2011,11,6,5,59,59)},
        {"America/New_York",    new CalFields(2011,11,6,2,0,0),     new CalFields(2011,11,6,7,0,0),     new CalFields(2011,11,6,7,0,0)},
        {"America/New_York",    new CalFields(2011,11,6,2,0,1),     new CalFields(2011,11,6,7,0,1),     new CalFields(2011,11,6,7,0,1)},

        {"Australia/Lord_Howe", new CalFields(2011,4,3,1,29,59),    new CalFields(2011,4,2,14,29,59),   new CalFields(2011,4,2,14,29,59)},
        {"Australia/Lord_Howe", new CalFields(2011,4,3,1,30,0),     new CalFields(2011,4,2,15,0,0),     new CalFields(2011,4,2,14,30,0)},
        {"Australia/Lord_Howe", new CalFields(2011,4,3,1,45,0),     new CalFields(2011,4,2,15,15,0),    new CalFields(2011,4,2,14,45,0)},
        {"Australia/Lord_Howe", new CalFields(2011,4,3,1,59,59),    new CalFields(2011,4,2,15,29,59),   new CalFields(2011,4,2,14,59,59)},
        {"Australia/Lord_Howe", new CalFields(2011,4,3,2,0,0),      new CalFields(2011,4,2,15,30,0),    new CalFields(2011,4,2,15,30,0)},
        {"Australia/Lord_Howe", new CalFields(2011,4,3,2,0,1),      new CalFields(2011,4,2,15,30,1),    new CalFields(2011,4,2,15,30,1)},
    };

    Calendar calGMT = Calendar.getInstance(TimeZone.GMT_ZONE);

    Calendar calDefault = Calendar.getInstance();
    Calendar calLast = Calendar.getInstance();
    Calendar calFirst = Calendar.getInstance();

    calFirst.setRepeatedWallTimeOption(Calendar.WALLTIME_FIRST);
    calLast.setRepeatedWallTimeOption(Calendar.WALLTIME_LAST);

    for (Object[] test : TESTDATA) {
        String tzid = (String)test[0];
        TimeZone tz = TimeZone.getTimeZone(tzid);
        CalFields in = (CalFields)test[1];
        CalFields expLastGMT = (CalFields)test[2];
        CalFields expFirstGMT = (CalFields)test[3];

        // WALLTIME_LAST
        calLast.setTimeZone(tz);
        in.setTo(calLast);
        calGMT.setTimeInMillis(calLast.getTimeInMillis());
        CalFields outLastGMT = CalFields.createFrom(calGMT);
        if (!outLastGMT.equals(expLastGMT)) {
            errln("Fail: WALLTIME_LAST " + in + "[" + tzid + "] is parsed as " + outLastGMT + "[GMT]. Expected: " + expLastGMT + "[GMT]");
        }

        // default
        calDefault.setTimeZone(tz);
        in.setTo(calDefault);
        calGMT.setTimeInMillis(calDefault.getTimeInMillis());
        CalFields outDefGMT = CalFields.createFrom(calGMT);
        if (!outDefGMT.equals(expLastGMT)) {
            errln("Fail: (default) " + in + "[" + tzid + "] is parsed as " + outDefGMT + "[GMT]. Expected: " + expLastGMT + "[GMT]");
        }

        // WALLTIME_FIRST
        calFirst.setTimeZone(tz);
        in.setTo(calFirst);
        calGMT.setTimeInMillis(calFirst.getTimeInMillis());
        CalFields outFirstGMT = CalFields.createFrom(calGMT);
        if (!outFirstGMT.equals(expFirstGMT)) {
            errln("Fail: WALLTIME_FIRST " + in + "[" + tzid + "] is parsed as " + outFirstGMT + "[GMT]. Expected: " + expFirstGMT + "[GMT]");
        }
    }
}