当前位置: 首页>>代码示例>>Java>>正文


Java ULocale.addLikelySubtags方法代码示例

本文整理汇总了Java中com.ibm.icu.util.ULocale.addLikelySubtags方法的典型用法代码示例。如果您正苦于以下问题:Java ULocale.addLikelySubtags方法的具体用法?Java ULocale.addLikelySubtags怎么用?Java ULocale.addLikelySubtags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.ibm.icu.util.ULocale的用法示例。


在下文中一共展示了ULocale.addLikelySubtags方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isSubdivision

import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
/**
 * @param locale
 * @param subtag
 * @return
 */
private boolean isSubdivision(ULocale locale, String subtag) {
    // First check if the subtag is valid
    if (subtag.length() < 3) {
        return false;
    }
    String region = subtag.substring(0, subtag.charAt(0) <= '9' ? 3 : 2);
    String subdivision = subtag.substring(region.length());
    if (ValidIdentifiers.isValid(Datatype.subdivision, datasubtypes, region, subdivision) == null) {
        return false;
    }
    // Then check for consistency with the locale's region
    String localeRegion = locale.getCountry();
    if (localeRegion.isEmpty()) {
        ULocale max = ULocale.addLikelySubtags(locale);
        localeRegion = max.getCountry();
    }
    if (!region.equalsIgnoreCase(localeRegion)) {
        return false;
    }
    return true;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:27,代码来源:LocaleValidityChecker.java

示例2: getAllowedHourFormats

import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
private void getAllowedHourFormats(ULocale uLocale) {
    // key can be either region or locale (lang_region)
    //        ZW{
    //            allowed{
    //                "h",
    //                "H",
    //            }
    //            preferred{"h"}
    //        }
    //        af_ZA{
    //            allowed{
    //                "h",
    //                "H",
    //                "hB",
    //                "hb",
    //            }
    //            preferred{"h"}
    //        }

    ULocale max = ULocale.addLikelySubtags(uLocale);
    String country = max.getCountry();
    if (country.isEmpty()) {
        country = "001";
    }
    String langCountry = max.getLanguage() + "_" + country;
    String[] list = LOCALE_TO_ALLOWED_HOUR.get(langCountry);
    if (list == null) {
        list = LOCALE_TO_ALLOWED_HOUR.get(country);
        if (list == null) {
            list = LAST_RESORT_ALLOWED_HOUR_FORMAT;
        }
    }
    allowedHourFormats = list;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:35,代码来源:DateTimePatternGenerator.java

示例3: getTargetRegion

import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
/**
 * Private method returning the target region. The target regions is determined by
 * the locale of this instance. When a generic name is coming from
 * a meta zone, this region is used for checking if the time zone
 * is a reference zone of the meta zone.
 *
 * @return the target region
 */
private synchronized String getTargetRegion() {
    if (_region == null) {
        _region = _locale.getCountry();
        if (_region.length() == 0) {
            ULocale tmp = ULocale.addLikelySubtags(_locale);
            _region = tmp.getCountry();
            if (_region.length() == 0) {
                _region = "001";
            }
        }
    }
    return _region;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:22,代码来源:TimeZoneFormat.java

示例4: findCodeFromLocale

import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
/**
 * Helper function to find the code from locale.
 * @param locale The locale.
 */
private static int[] findCodeFromLocale(ULocale locale) {
    int[] result = getCodesFromLocale(locale);
    if(result != null) {
        return result;
    }
    ULocale likely = ULocale.addLikelySubtags(locale);
    return getCodesFromLocale(likely);
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:13,代码来源:UScript.java

示例5: getTargetRegion

import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
private String getTargetRegion() {
    if (_region == null) {
        String region = _locale.getCountry();
        if (region.length() == 0) {
            ULocale tmp = ULocale.addLikelySubtags(_locale);
            region = tmp.getCountry();
            if (region.length() == 0) {
                region = "001";
            }
        }
        _region = region;
    }
    return _region;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:15,代码来源:TZDBTimeZoneNames.java


注:本文中的com.ibm.icu.util.ULocale.addLikelySubtags方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。