當前位置: 首頁>>代碼示例>>Java>>正文


Java Locale.getUnicodeLocaleType方法代碼示例

本文整理匯總了Java中java.util.Locale.getUnicodeLocaleType方法的典型用法代碼示例。如果您正苦於以下問題:Java Locale.getUnicodeLocaleType方法的具體用法?Java Locale.getUnicodeLocaleType怎麽用?Java Locale.getUnicodeLocaleType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.Locale的用法示例。


在下文中一共展示了Locale.getUnicodeLocaleType方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isSupportedCalendarLocale

import java.util.Locale; //導入方法依賴的package包/類
private static boolean isSupportedCalendarLocale(Locale locale) {
    Locale base = locale;

    if (base.hasExtensions() || base.getVariant() != "") {
        base = new Locale.Builder()
                        .setLocale(locale)
                        .clearExtensions()
                        .build();
    }

    if (!supportedLocaleSet.contains(base)) {
        return false;
    }

    String requestedCalType = locale.getUnicodeLocaleType("ca");
    String nativeCalType =
        getCalendarID(base.toLanguageTag()).replaceFirst("gregorian", "gregory");

    if (requestedCalType == null) {
        return Calendar.getAvailableCalendarTypes().contains(nativeCalType);
    } else {
        return requestedCalType.equals(nativeCalType);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:25,代碼來源:HostLocaleProviderAdapterImpl.java

示例2: isSupportedNativeDigitLocale

import java.util.Locale; //導入方法依賴的package包/類
private static boolean isSupportedNativeDigitLocale(Locale locale) {
    // special case for th_TH_TH
    if (JRELocaleConstants.TH_TH_TH.equals(locale)) {
        return isNativeDigit("th-TH");
    }

    String numtype = null;
    Locale base = locale;
    if (locale.hasExtensions()) {
        numtype = locale.getUnicodeLocaleType("nu");
        base = locale.stripExtensions();
    }

    if (supportedLocaleSet.contains(base)) {
        // Only supports Latin or Thai (in thai locales) digits.
        if (numtype == null || numtype.equals("latn")) {
            return true;
        } else if (locale.getLanguage().equals("th")) {
            return "thai".equals(numtype) &&
                   isNativeDigit(locale.toLanguageTag());
        }
    }

    return false;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:26,代碼來源:HostLocaleProviderAdapterImpl.java

示例3: isSupportedCalendarLocale

import java.util.Locale; //導入方法依賴的package包/類
private static boolean isSupportedCalendarLocale(Locale locale) {
    Locale base = stripVariantAndExtensions(locale);

    if (!supportedLocaleSet.contains(base)) {
        return false;
    }

    int calid = getCalendarID(base.toLanguageTag());
    if (calid <= 0 || calid >= calIDToLDML.length) {
        return false;
    }

    String requestedCalType = locale.getUnicodeLocaleType("ca");
    String nativeCalType = calIDToLDML[calid]
            .replaceFirst("_.*", ""); // remove locale part.

    if (requestedCalType == null) {
        return Calendar.getAvailableCalendarTypes().contains(nativeCalType);
    } else {
        return requestedCalType.equals(nativeCalType);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:23,代碼來源:HostLocaleProviderAdapterImpl.java

示例4: isSupportedLocale

import java.util.Locale; //導入方法依賴的package包/類
@Override
public boolean isSupportedLocale(Locale locale) {
    if (Locale.ROOT.equals(locale)) {
        return true;
    }
    String calendarType = null;
    if (locale.hasExtensions()) {
        calendarType = locale.getUnicodeLocaleType("ca");
        locale = locale.stripExtensions();
    }

    if (calendarType != null) {
        switch (calendarType) {
        case "buddhist":
        case "japanese":
        case "gregory":
        case "islamic":
        case "roc":
            break;
        default:
            // Unknown calendar type
            return false;
        }
    }
    if (langtags.contains(locale.toLanguageTag())) {
        return true;
    }
    if (type == LocaleProviderAdapter.Type.JRE) {
        String oldname = locale.toString().replace('_', '-');
        return langtags.contains(oldname);
    }
    return false;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:34,代碼來源:CalendarNameProviderImpl.java

示例5: isSupportedCalendarLocale

import java.util.Locale; //導入方法依賴的package包/類
private static boolean isSupportedCalendarLocale(Locale locale) {
    Locale base = locale;

    if (base.hasExtensions() || base.getVariant() != "") {
        // strip off extensions and variant.
        base = new Locale.Builder()
                        .setLocale(locale)
                        .clearExtensions()
                        .build();
    }

    if (!supportedLocaleSet.contains(base)) {
        return false;
    }

    int calid = getCalendarID(base.toLanguageTag());
    if (calid <= 0 || calid >= calIDToLDML.length) {
        return false;
    }

    String requestedCalType = locale.getUnicodeLocaleType("ca");
    String nativeCalType = calIDToLDML[calid]
            .replaceFirst("_.*", ""); // remove locale part.

    if (requestedCalType == null) {
        return Calendar.getAvailableCalendarTypes().contains(nativeCalType);
    } else {
        return requestedCalType.equals(nativeCalType);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:31,代碼來源:HostLocaleProviderAdapterImpl.java


注:本文中的java.util.Locale.getUnicodeLocaleType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。