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


Java Locale.Builder方法代碼示例

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


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

示例1: getCalendarLocale

import java.util.Locale; //導入方法依賴的package包/類
private static Locale getCalendarLocale(Locale locale) {
    int calid = getCalendarID(locale.toLanguageTag());
    if (calid > 0 && calid < calIDToLDML.length) {
        Locale.Builder lb = new Locale.Builder();
        String[] caltype = calIDToLDML[calid].split("_");
        if (caltype.length > 1) {
            lb.setLocale(Locale.forLanguageTag(caltype[1]));
        } else {
            lb.setLocale(locale);
        }
        lb.setUnicodeLocaleKeyword("ca", caltype[0]);
        return lb.build();
    }

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

示例2: createLocale

import java.util.Locale; //導入方法依賴的package包/類
private static Locale createLocale(@NonNull String language, @Nullable String region, @Nullable String script) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Locale.Builder localeBuilder = new Locale.Builder();
        localeBuilder.setLanguage(language);
        if (region != null) {
            localeBuilder.setRegion(region);
        }
        if (script != null) {
            localeBuilder.setScript(script);
        }
        return localeBuilder.build();
    } else {
        if (region == null) {
            return new Locale(language);
        } else if (script == null) {
            return new Locale(language, region);
        } else {
            return new Locale(language, region, script);
        }
    }
}
 
開發者ID:powdream,項目名稱:google-speech-api-android,代碼行數:22,代碼來源:SupportedLanguageConverter.java

示例3: getCalendarLocale

import java.util.Locale; //導入方法依賴的package包/類
private static Locale getCalendarLocale(Locale locale) {
    int calid = getCalendarID(stripVariantAndExtensions(locale).toLanguageTag());
    if (calid > 0 && calid < calIDToLDML.length) {
        Locale.Builder lb = new Locale.Builder();
        String[] caltype = calIDToLDML[calid].split("_");
        if (caltype.length > 1) {
            lb.setLocale(Locale.forLanguageTag(caltype[1]));
        } else {
            lb.setLocale(locale);
        }
        lb.setUnicodeLocaleKeyword("ca", caltype[0]);
        return lb.build();
    }

    return locale;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:HostLocaleProviderAdapterImpl.java

示例4: getNumberLocale

import java.util.Locale; //導入方法依賴的package包/類
private static Locale getNumberLocale(Locale src) {
    if (JRELocaleConstants.TH_TH.equals(src)) {
        if (isNativeDigit("th-TH")) {
            Locale.Builder lb = new Locale.Builder().setLocale(src);
            lb.setUnicodeLocaleKeyword("nu", "thai");
            return lb.build();
        }
    }

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

示例5: test_lookupLocale

import java.util.Locale; //導入方法依賴的package包/類
@Test(dataProvider = "calendarsystemtype")
public void test_lookupLocale(Chronology chrono, String calendarType) {
    Locale.Builder builder = new Locale.Builder().setLanguage("en").setRegion("CA");
    builder.setUnicodeLocaleKeyword("ca", calendarType);
    Locale locale = builder.build();
    assertEquals(Chronology.ofLocale(locale), chrono);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:8,代碼來源:TCKChronology.java

示例6: test_ofLocaleByType

import java.util.Locale; //導入方法依賴的package包/類
/**
 * Test lookup by calendarType of each chronology.
 * Verify that the calendar can be found by {@link java.time.chrono.Chronology#ofLocale}.
 */
@Test
public void test_ofLocaleByType() {
    // Test that all available chronologies can be successfully found using ofLocale
    Set<Chronology> chronos = Chronology.getAvailableChronologies();
    for (Chronology chrono : chronos) {
        Locale.Builder builder = new Locale.Builder().setLanguage("en").setRegion("CA");
        builder.setUnicodeLocaleKeyword("ca", chrono.getCalendarType());
        Locale locale = builder.build();
        assertEquals(Chronology.ofLocale(locale), chrono, "Lookup by type");
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:16,代碼來源:TCKChronology.java

示例7: test_HijrahTypeViaLocale

import java.util.Locale; //導入方法依賴的package包/類
@Test(dataProvider= "HijrahTypeNames")
public void test_HijrahTypeViaLocale(String calendarId, String calendarType) {
    Locale.Builder builder = new Locale.Builder();
    builder.setLanguage("en").setRegion("US");
    builder.setUnicodeLocaleKeyword("ca", calendarType);
    Locale locale = builder.build();
    Chronology chrono = Chronology.ofLocale(locale);
    System.out.printf(" Locale language tag: %s, Chronology ID: %s, type: %s%n",
            locale.toLanguageTag(), chrono, chrono.getCalendarType());
    Chronology expected = Chronology.of(calendarId);
    assertEquals(chrono, expected, "Expected chronology not found");
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:13,代碼來源:TestExampleCode.java

示例8: main

import java.util.Locale; //導入方法依賴的package包/類
public static void main(String[] args) {
    Locale reservedLocale = Locale.getDefault();
    try {
        Locale.Builder builder = new Locale.Builder();

        base = builder.setLanguage(System.getProperty("user.language", ""))
              .setScript(System.getProperty("user.script", ""))
              .setRegion(System.getProperty("user.country", ""))
              .setVariant(System.getProperty("user.variant", "")).build();
        disp = builder.setLanguage(
                System.getProperty("user.language.display",
                            Locale.getDefault().getLanguage()))
                    .setScript(System.getProperty("user.script.display",
                            Locale.getDefault().getScript()))
                    .setRegion(System.getProperty("user.country.display",
                            Locale.getDefault().getCountry()))
                    .setVariant(System.getProperty("user.variant.display",
                            Locale.getDefault().getVariant())).build();
        fmt = builder.setLanguage(System.getProperty("user.language.format",
                            Locale.getDefault().getLanguage()))
                   .setScript(System.getProperty("user.script.format",
                            Locale.getDefault().getScript()))
                   .setRegion(System.getProperty("user.country.format",
                            Locale.getDefault().getCountry()))
                   .setVariant(System.getProperty("user.variant.format",
                              Locale.getDefault().getVariant())).build();
        checkDefault();
        testGetSetDefault();
        testBug7079486();
    } finally {
        // restore the reserved locale
        Locale.setDefault(reservedLocale);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:35,代碼來源:LocaleCategory.java

示例9: main

import java.util.Locale; //導入方法依賴的package包/類
public static void main(String[] args) {
    Locale reservedLocale = Locale.getDefault();
    if (TestUtils.hasSpecialVariant(reservedLocale)) {
        System.out.println("Skipping this test because locale is " + reservedLocale);
        return;
    }

    try {
        Locale.Builder builder = new Locale.Builder();

        base = builder.setLanguage(System.getProperty("user.language", ""))
              .setScript(System.getProperty("user.script", ""))
              .setRegion(System.getProperty("user.country", ""))
              .setVariant(System.getProperty("user.variant", "")).build();
        disp = builder.setLanguage(
                System.getProperty("user.language.display",
                            Locale.getDefault().getLanguage()))
                    .setScript(System.getProperty("user.script.display",
                            Locale.getDefault().getScript()))
                    .setRegion(System.getProperty("user.country.display",
                            Locale.getDefault().getCountry()))
                    .setVariant(System.getProperty("user.variant.display",
                            Locale.getDefault().getVariant())).build();
        fmt = builder.setLanguage(System.getProperty("user.language.format",
                            Locale.getDefault().getLanguage()))
                   .setScript(System.getProperty("user.script.format",
                            Locale.getDefault().getScript()))
                   .setRegion(System.getProperty("user.country.format",
                            Locale.getDefault().getCountry()))
                   .setVariant(System.getProperty("user.variant.format",
                              Locale.getDefault().getVariant())).build();
        checkDefault();
        testGetSetDefault();
        testBug7079486();
    } finally {
        // restore the reserved locale
        Locale.setDefault(reservedLocale);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:40,代碼來源:LocaleCategory.java


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