Java Code Examples for java.util.Calendar.getLeastMaximum()

The following are Jave code examples for showing how to use getLeastMaximum() 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);
        }
    }
}
 
Example 2
Project: openjdk-jdk10   File: CalendarRegression.java   View Source Code Vote up 6 votes
/**
 * Make sure maximum for HOUR field is 11, not 12.
 */
public void Test4118384() {
    Calendar cal = Calendar.getInstance();
    if (cal.getMaximum(HOUR) != 11
            || cal.getLeastMaximum(HOUR) != 11
            || cal.getActualMaximum(HOUR) != 11) {
        errln("Fail: maximum of HOUR field should be 11");
    }
}
 
Example 3
Project: airgram   File: FastDatePrinter.java   View Source Code Vote up 5 votes
/**
 * {@inheritDoc}
 */
@Override
public void appendTo(final StringBuffer buffer, final Calendar calendar) {
    int value = calendar.get(Calendar.HOUR);
    if (value == 0) {
        value = calendar.getLeastMaximum(Calendar.HOUR) + 1;
    }
    mRule.appendTo(buffer, value);
}
 
Example 4
Project: lams   File: FastDateFormat.java   View Source Code Vote up 5 votes
/**
 * {@inheritDoc}
 */
public void appendTo(StringBuffer buffer, Calendar calendar) {
    int value = calendar.get(Calendar.HOUR);
    if (value == 0) {
        value = calendar.getLeastMaximum(Calendar.HOUR) + 1;
    }
    mRule.appendTo(buffer, value);
}
 
Example 5
Project: PlusGram   File: FastDatePrinter.java   View Source Code Vote up 5 votes
/**
 * {@inheritDoc}
 */
@Override
public void appendTo(final StringBuffer buffer, final Calendar calendar) {
    int value = calendar.get(Calendar.HOUR);
    if (value == 0) {
        value = calendar.getLeastMaximum(Calendar.HOUR) + 1;
    }
    mRule.appendTo(buffer, value);
}