Java Code Examples for java.util.Calendar.FIELD_COUNT

The following are Jave code examples for showing how to use FIELD_COUNT of the java.util.Calendar class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: openjdk-jdk10   File: BuddhistCalendarTest.java   View Source Code Vote up 7 votes
/**
 * 4956227: getLeastMaximum(WEEK_OF_MONTH) return diff. val. for Greg. and Buddhist Calendar
 */
static void testLeastMax() {
    Calendar bc = getBuddhistCalendar();
    // Specify THAI_LOCALE to get the same params for WEEK
    // calculations (6904680).
    Calendar gc = new GregorianCalendar(THAI_LOCALE);
    for (int f = 0; f < Calendar.FIELD_COUNT; f++) {
        if (f == ERA || f == YEAR) {
            continue;
        }
        int bn = bc.getLeastMaximum(f);
        int gn = gc.getLeastMaximum(f);
        if (bn != gn) {
            throw new RuntimeException("inconsistent Least Max value for " + Koyomi.getFieldName(f)
                                       + ": Buddhist=" + bn
                                       + ": Gregorian=" + gn);
        }
    }
}