本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}