Search in sources :

Example 71 with Locale

use of java.util.Locale in project morphia by mongodb.

the class LocaleConverterTest method shouldEncodeAndDecodeBuiltInLocale.

@Test
public void shouldEncodeAndDecodeBuiltInLocale() throws Exception {
    // given
    LocaleConverter converter = new LocaleConverter();
    Locale expectedLocale = Locale.CANADA_FRENCH;
    // when
    Locale decodedLocale = (Locale) converter.decode(Locale.class, converter.encode(expectedLocale));
    // then
    assertThat(decodedLocale, is(expectedLocale));
}
Also used : Locale(java.util.Locale) Test(org.junit.Test)

Example 72 with Locale

use of java.util.Locale in project jersey by jersey.

the class LocaleProviderTest method testFromString.

@Test
public void testFromString() throws Exception {
    final LocaleProvider instance = new LocaleProvider();
    assertEquals(new Locale("en"), instance.fromString("en"));
    assertEquals(new Locale("en", "us"), instance.fromString("en-us"));
}
Also used : Locale(java.util.Locale) LocaleProvider(org.glassfish.jersey.message.internal.LocaleProvider) Test(org.junit.Test)

Example 73 with Locale

use of java.util.Locale in project jersey by jersey.

the class LocaleProviderTest method testToString.

@Test
public void testToString() {
    final LocaleProvider instance = new LocaleProvider();
    assertEquals("en", instance.toString(new Locale("en")));
    assertEquals("en-US", instance.toString(new Locale("en", "us")));
}
Also used : Locale(java.util.Locale) LocaleProvider(org.glassfish.jersey.message.internal.LocaleProvider) Test(org.junit.Test)

Example 74 with Locale

use of java.util.Locale in project languagetool by languagetool-org.

the class ResourceBundleTools method getMessageBundle.

/**
   * Gets the ResourceBundle (i18n strings) for the given user interface language.
   */
static ResourceBundle getMessageBundle(Language lang) {
    try {
        ResourceBundle bundle = ResourceBundle.getBundle(MESSAGE_BUNDLE, lang.getLocaleWithCountryAndVariant());
        if (!isValidBundleFor(lang, bundle)) {
            bundle = ResourceBundle.getBundle(MESSAGE_BUNDLE, lang.getLocale());
            if (!isValidBundleFor(lang, bundle)) {
                // happens if 'xx' is requested but only a MessagesBundle_xx_YY.properties exists:
                Language defaultVariant = lang.getDefaultLanguageVariant();
                if (defaultVariant != null && defaultVariant.getCountries().length > 0) {
                    Locale locale = new Locale(defaultVariant.getShortCode(), defaultVariant.getCountries()[0]);
                    bundle = ResourceBundle.getBundle(MESSAGE_BUNDLE, locale);
                }
            }
        }
        ResourceBundle fallbackBundle = ResourceBundle.getBundle(MESSAGE_BUNDLE, Locale.ENGLISH);
        return new ResourceBundleWithFallback(bundle, fallbackBundle);
    } catch (MissingResourceException e) {
        return ResourceBundle.getBundle(MESSAGE_BUNDLE, Locale.ENGLISH);
    }
}
Also used : Locale(java.util.Locale) MissingResourceException(java.util.MissingResourceException) ResourceBundle(java.util.ResourceBundle)

Example 75 with Locale

use of java.util.Locale in project storm by apache.

the class ConsolePreparableReporter method prepare.

@Override
public void prepare(MetricRegistry metricsRegistry, Map stormConf) {
    LOG.debug("Preparing...");
    ConsoleReporter.Builder builder = ConsoleReporter.forRegistry(metricsRegistry);
    builder.outputTo(System.out);
    Locale locale = MetricsUtils.getMetricsReporterLocale(stormConf);
    if (locale != null) {
        builder.formattedFor(locale);
    }
    TimeUnit rateUnit = MetricsUtils.getMetricsRateUnit(stormConf);
    if (rateUnit != null) {
        builder.convertRatesTo(rateUnit);
    }
    TimeUnit durationUnit = MetricsUtils.getMetricsDurationUnit(stormConf);
    if (durationUnit != null) {
        builder.convertDurationsTo(durationUnit);
    }
    reporter = builder.build();
}
Also used : Locale(java.util.Locale) ConsoleReporter(com.codahale.metrics.ConsoleReporter) TimeUnit(java.util.concurrent.TimeUnit)

Aggregations

Locale (java.util.Locale)5854 Test (org.junit.Test)902 HashMap (java.util.HashMap)548 GenericValue (org.apache.ofbiz.entity.GenericValue)504 ArrayList (java.util.ArrayList)486 Delegator (org.apache.ofbiz.entity.Delegator)484 GenericEntityException (org.apache.ofbiz.entity.GenericEntityException)398 IOException (java.io.IOException)313 LocalDispatcher (org.apache.ofbiz.service.LocalDispatcher)296 Date (java.util.Date)273 GenericServiceException (org.apache.ofbiz.service.GenericServiceException)271 Map (java.util.Map)244 BigDecimal (java.math.BigDecimal)214 SimpleDateFormat (java.text.SimpleDateFormat)198 ResourceBundle (java.util.ResourceBundle)197 File (java.io.File)166 LinkedList (java.util.LinkedList)158 ULocale (android.icu.util.ULocale)156 List (java.util.List)147 Test (org.junit.jupiter.api.Test)132