Java Code Examples for android.icu.util.Calendar#HOUR

The following examples show how to use android.icu.util.Calendar#HOUR . 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: DateIntervalInfo.java    From j2objc with Apache License 2.0 6 votes vote down vote up
/**
 * Processes the pattern letter
 * @param patternLetter
 * @return Pattern letter
 */
private CharSequence validateAndProcessPatternLetter(CharSequence patternLetter) {
    // Check that patternLetter is just one letter
    if (patternLetter.length() != 1) { return null; }

    // Check that the pattern letter is accepted
    char letter = patternLetter.charAt(0);
    if (ACCEPTED_PATTERN_LETTERS.indexOf(letter) < 0) {
        return null;
    }

    // Replace 'h' for 'H'
    if (letter == CALENDAR_FIELD_TO_PATTERN_LETTER[Calendar.HOUR_OF_DAY].charAt(0)) {
        patternLetter = CALENDAR_FIELD_TO_PATTERN_LETTER[Calendar.HOUR];
    }

    return patternLetter;
}
 
Example 2
Source File: DateIntervalFormat.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * @deprecated This API is ICU internal only.
 * @hide original deprecated declaration
 * @hide draft / provisional / internal are hidden on Android
 */
@Deprecated
public String getPatterns(Calendar fromCalendar,
        Calendar toCalendar, 
        Output<String> part2) {
    // First, find the largest different calendar field.
    int field;
    if ( fromCalendar.get(Calendar.ERA) != toCalendar.get(Calendar.ERA) ) {
        field = Calendar.ERA;
    } else if ( fromCalendar.get(Calendar.YEAR) != 
                toCalendar.get(Calendar.YEAR) ) {
        field = Calendar.YEAR;
    } else if ( fromCalendar.get(Calendar.MONTH) !=
                toCalendar.get(Calendar.MONTH) ) {
        field = Calendar.MONTH;
    } else if ( fromCalendar.get(Calendar.DATE) !=
                toCalendar.get(Calendar.DATE) ) {
        field = Calendar.DATE;
    } else if ( fromCalendar.get(Calendar.AM_PM) !=
                toCalendar.get(Calendar.AM_PM) ) {
        field = Calendar.AM_PM;
    } else if ( fromCalendar.get(Calendar.HOUR) !=
                toCalendar.get(Calendar.HOUR) ) {
        field = Calendar.HOUR;
    } else if ( fromCalendar.get(Calendar.MINUTE) !=
                toCalendar.get(Calendar.MINUTE) ) {
        field = Calendar.MINUTE;
    } else if ( fromCalendar.get(Calendar.SECOND) !=
                toCalendar.get(Calendar.SECOND) ) {
        field = Calendar.SECOND;
    } else {
        return null;
    }
    PatternInfo intervalPattern = fIntervalPatterns.get(
            DateIntervalInfo.CALENDAR_FIELD_TO_PATTERN_LETTER[field]);
    part2.value = intervalPattern.getSecondPart();
    return intervalPattern.getFirstPart();
}