当前位置: 首页>>代码示例>>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;未经允许,请勿转载。