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

The following examples show how to use java.util.Calendar#getLeastMaximum() . 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: BuddhistCalendarTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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
Source File: 1_FastDateFormat.java    From SimFix with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@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 3
Source File: Lang_38_FastDateFormat_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * {@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 4
Source File: DateSet.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/** Sets the given {@code value} with the specified unit in the calendar; For {@link Calendar#YEAR}, caps the value. */
@Override
void integerManipulation(Callable<Void> stopChecker, Calendar cal, int unit, int value) {
	if (unit == Calendar.YEAR) {
		if (value < -cal.getLeastMaximum(unit)) {
			value = -cal.getLeastMaximum(unit);
		} else if (value >= cal.getMaximum(unit)) {
			value = cal.getMaximum(unit) - 1;
		}
	}
	cal.set(unit, value);
}
 
Example 5
Source File: Lang_56_FastDateFormat_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * {@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 6
Source File: Arja_0071_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * {@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 7
Source File: Lang_56_FastDateFormat_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * {@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 8
Source File: FastDateFormat.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@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 9
Source File: 1_FastDateFormat.java    From SimFix with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@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 10
Source File: FastDateFormat.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@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 11
Source File: FastDatePrinter.java    From logging-log4j2 with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void appendTo(final Appendable buffer, final Calendar calendar) throws IOException {
    int value = calendar.get(Calendar.HOUR);
    if (value == 0) {
        value = calendar.getLeastMaximum(Calendar.HOUR) + 1;
    }
    mRule.appendTo(buffer, value);
}
 
Example 12
Source File: Arja_0097_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * {@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 13
Source File: Elixir_008_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * {@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 14
Source File: Arja_00150_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * {@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 15
Source File: CalendarRegression.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 16
Source File: Lang_50_FastDateFormat_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * {@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 17
Source File: FastDateFormat.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@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 18
Source File: Arja_00117_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * {@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 19
Source File: FastDatePrinter.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@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 20
Source File: FastDateFormat.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@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);
}