Logo Search packages:      
Sourcecode: icu version File versions

DateIntervalFormat *U_EXPORT2 DateIntervalFormat::createInstance ( const UnicodeString skeleton,
const Locale locale,
UErrorCode status 
) [static]

Construct a DateIntervalFormat from skeleton and a given locale.

In this factory method, the date interval pattern information is load from resource files. Users are encouraged to created date interval formatter this way and to use the pre-defined skeleton macros.

There are pre-defined skeletons (defined in udate.h) having predefined interval patterns in resource files. Users are encouraged to use those macros. For example: DateIntervalFormat::createInstance(UDAT_MONTH_DAY, status)

The given Locale provides the interval patterns. For example, for en_GB, if skeleton is UDAT_YEAR_ABBR_MONTH_WEEKDAY_DAY, which is "yMMMEEEd", the interval patterns defined in resource file to above skeleton are: "EEE, d MMM, yyyy - EEE, d MMM, yyyy" for year differs, "EEE, d MMM - EEE, d MMM, yyyy" for month differs, "EEE, d - EEE, d MMM, yyyy" for day differs,

Parameters:
skeleton the skeleton on which interval format based.
locale the given locale
status output param set to success/failure code on exit
Returns:
a date time interval formatter which the caller owns. ICU 4.0

Definition at line 74 of file dtitvfmt.cpp.

References create(), UnicodeString::extract(), and UnicodeString::length().

                                                       {
#ifdef DTITVFMT_DEBUG
    char result[1000];
    char result_1[1000];
    char mesg[2000];
    skeleton.extract(0,  skeleton.length(), result, "UTF-8");
    UnicodeString pat;
    ((SimpleDateFormat*)dtfmt)->toPattern(pat);
    pat.extract(0,  pat.length(), result_1, "UTF-8");
    sprintf(mesg, "skeleton: %s; pattern: %s\n", result, result_1);
    PRINTMESG(mesg)
#endif

    DateIntervalInfo* dtitvinf = new DateIntervalInfo(locale, status);
    return create(locale, dtitvinf, &skeleton, status);
}


Generated by  Doxygen 1.6.0   Back to index