Logo Search packages:      
Sourcecode: icu version File versions

UnicodeString & DateIntervalFormat::fallbackFormat ( Calendar fromCalendar,
Calendar toCalendar,
UnicodeString appendTo,
FieldPosition pos,
UErrorCode status 
) const [private]

Below are for generating interval patterns local to the formatter Format 2 Calendars using fall-back interval pattern

The full pattern used in this fall-back format is the full pattern of the date formatter.

Parameters:
fromCalendar calendar set to the from date in date interval to be formatted into date interval string
toCalendar calendar set to the to date in date interval to be formatted into date interval string
appendTo Output parameter to receive result. Result is appended to existing contents.
pos On input: an alignment field, if desired. On output: the offsets of the alignment field.
status output param set to success/failure code on exit
Returns:
Reference to 'appendTo' parameter.

For internal use only.

ICU 4.0

Definition at line 1224 of file dtitvfmt.cpp.

References Formattable::adoptString(), UnicodeString::append(), fDateFormat, fInfo, MessageFormat::format(), SimpleDateFormat::format(), DateIntervalInfo::getFallbackIntervalPattern(), U_FAILURE, and U_SUCCESS.

Referenced by format().

                                                             {
    if ( U_FAILURE(status) ) {
        return appendTo;
    }
    // the fall back
    // no need delete earlierDate and laterDate since they are adopted
    UnicodeString* earlierDate = new UnicodeString();
    *earlierDate = fDateFormat->format(fromCalendar, *earlierDate, pos);
    UnicodeString* laterDate = new UnicodeString();
    *laterDate = fDateFormat->format(toCalendar, *laterDate, pos);
    UnicodeString fallbackPattern;
    fInfo->getFallbackIntervalPattern(fallbackPattern);
    Formattable fmtArray[2];
    fmtArray[0].adoptString(earlierDate);
    fmtArray[1].adoptString(laterDate);
    
    UnicodeString fallback;
    MessageFormat::format(fallbackPattern, fmtArray, 2, fallback, status);
    if ( U_SUCCESS(status) ) {
        appendTo.append(fallback);
    }
    return appendTo;
}


Generated by  Doxygen 1.6.0   Back to index