Java Code Examples for com.ibm.icu.util.ULocale#toString()

The following examples show how to use com.ibm.icu.util.ULocale#toString() . 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: DateTimePatternGenerator.java    From fitnotifications with Apache License 2.0 6 votes vote down vote up
/**
 * Construct a frozen instance of DateTimePatternGenerator for a
 * given locale.  This method returns a cached frozen instance of
 * DateTimePatternGenerator, so less expensive than the regular
 * factory method.
 * @param uLocale The locale to pass.
 * @return A frozen DateTimePatternGenerator.
 * @internal
 * @deprecated This API is ICU internal only.
 */
@Deprecated
public static DateTimePatternGenerator getFrozenInstance(ULocale uLocale) {
    String localeKey = uLocale.toString();
    DateTimePatternGenerator result = DTPNG_CACHE.get(localeKey);
    if (result != null) {
        return result;
    }

    result = new DateTimePatternGenerator();
    result.initData(uLocale);

    // freeze and cache
    result.freeze();
    DTPNG_CACHE.put(localeKey, result);
    return result;
}
 
Example 2
Source File: DateIntervalFormat.java    From fitnotifications with Apache License 2.0 6 votes vote down vote up
private void initializePattern(ICUCache<String, Map<String, PatternInfo>> cache) { 
    String fullPattern = fDateFormat.toPattern();
    ULocale locale = fDateFormat.getLocale();
    String key = null;
    Map<String, PatternInfo> patterns = null;
    if (cache != null) {
        if ( fSkeleton != null ) {
            key = locale.toString() + "+" + fullPattern + "+" + fSkeleton;
        } else {
            key = locale.toString() + "+" + fullPattern;
        }
        patterns = cache.get(key);
    }
    if (patterns == null) {
        Map<String, PatternInfo> intervalPatterns = initializeIntervalPattern(fullPattern, locale);
        patterns = Collections.unmodifiableMap(intervalPatterns);
        if (cache != null) {
            cache.put(key, patterns);
        }
    } 
    fIntervalPatterns = patterns;
}
 
Example 3
Source File: DateIntervalInfo.java    From fitnotifications with Apache License 2.0 5 votes vote down vote up
private void initializeData(ULocale locale)
{
    String key = locale.toString();
    DateIntervalInfo dii = DIICACHE.get(key);
    if ( dii == null ) {
        // initialize data from scratch
        setup(locale);
        // Marking fIntervalPatterns read-only makes cloning cheaper.
        fIntervalPatternsReadOnly = true;
        // We freeze what goes in the cache without freezing this object.
        DIICACHE.put(key, ((DateIntervalInfo) clone()).freeze());
    } else {
        initializeFromReadOnlyPatterns(dii);
    }
}
 
Example 4
Source File: RelativeDateTimeFormatter.java    From fitnotifications with Apache License 2.0 4 votes vote down vote up
public RelativeDateTimeFormatterData get(ULocale locale) {
    String key = locale.toString();
    return cache.getInstance(key, locale);
}
 
Example 5
Source File: RbnfScannerProviderImpl.java    From fitnotifications with Apache License 2.0 4 votes vote down vote up
/**
 * Returns a collation-based scanner.
 *
 * Only primary differences are treated as significant.  This means that case
 * differences, accent differences, alternate spellings of the same letter
 * (e.g., ae and a-umlaut in German), ignorable characters, etc. are ignored in
 * matching the text.  In many cases, numerals will be accepted in place of words
 * or phrases as well.
 *
 * For example, all of the following will correctly parse as 255 in English in
 * lenient-parse mode:
 * <br>"two hundred fifty-five"
 * <br>"two hundred fifty five"
 * <br>"TWO HUNDRED FIFTY-FIVE"
 * <br>"twohundredfiftyfive"
 * <br>"2 hundred fifty-5"
 *
 * The Collator used is determined by the locale that was
 * passed to this object on construction.  The description passed to this object
 * on construction may supply additional collation rules that are appended to the
 * end of the default collator for the locale, enabling additional equivalences
 * (such as adding more ignorable characters or permitting spelled-out version of
 * symbols; see the demo program for examples).
 *
 * It's important to emphasize that even strict parsing is relatively lenient: it
 * will accept some text that it won't produce as output.  In English, for example,
 * it will correctly parse "two hundred zero" and "fifteen hundred".
 * 
 * @internal
 * @deprecated This API is ICU internal only.
 */
@Deprecated
public RbnfLenientScanner get(ULocale locale, String extras) {
    RbnfLenientScanner result = null;
    String key = locale.toString() + "/" + extras;
    synchronized(cache) {
        result = cache.get(key);
        if (result != null) {
            return result;
        }
    }
    result = createScanner(locale, extras);
    synchronized(cache) {
        cache.put(key, result);
    }
    return result;
}