@Test public void testUnderscoreLocale() { LocaleConverter localeConverter = new LocaleConverter(); Locale locale = localeConverter.convert("fr_FR"); assertEquals("fr", locale.getLanguage()); assertEquals("FR", locale.getCountry()); }
@Override public Locale convert(final String value) { String localeValue = value.trim(); if (localeValue.isEmpty()) { return null; } Locale locale = Locale.forLanguageTag(NORMALIZE_LOCALE_PATTERN.matcher(localeValue).replaceAll("-")); if (locale != Locale.ROOT && (locale.getLanguage() == null || locale.getLanguage().isEmpty())) { throw new IllegalArgumentException("Unable to resolve locale: " + value); } return locale; }
LocaleConverter implements Converter<Locale>, Serializable { @Override public Locale convert(final String value) { String localeValue = value.trim(); if (localeValue.isEmpty()) { return null; } Locale locale = Locale.forLanguageTag(NORMALIZE_LOCALE_PATTERN.matcher(localeValue).replaceAll("-")); if (locale != Locale.ROOT && (locale.getLanguage() == null || locale.getLanguage().isEmpty())) { throw new IllegalArgumentException("Unable to resolve locale: " + value); } return locale; } }
LocaleConverter implements Converter<Locale>, Serializable { @Override public Locale convert(final String value) { String localeValue = value.trim(); if (localeValue.isEmpty()) { return null; } Locale locale = Locale.forLanguageTag(NORMALIZE_LOCALE_PATTERN.matcher(localeValue).replaceAll("-")); if (locale != Locale.ROOT && (locale.getLanguage() == null || locale.getLanguage().isEmpty())) { throw new IllegalArgumentException("Unable to resolve locale: " + value); } return locale; } LocaleConverter(); }
LocaleConverter implements Converter<Locale>, Serializable { @Override public Locale convert(final String value) { String localeValue = value.trim(); if (localeValue.isEmpty()) { return null; } Locale locale = Locale.forLanguageTag(NORMALIZE_LOCALE_PATTERN.matcher(localeValue).replaceAll("-")); if (locale != Locale.ROOT && (locale.getLanguage() == null || locale.getLanguage().isEmpty())) { throw new IllegalArgumentException("Unable to resolve locale: " + value); } return locale; } LocaleConverter(); @Override Locale convert(final String value); }
LocaleConverter implements Converter<Locale>, Serializable { @Override public Locale convert(final String value) { String localeValue = value.trim(); if (localeValue.isEmpty()) { return null; } Locale locale = Locale.forLanguageTag(NORMALIZE_LOCALE_PATTERN.matcher(localeValue).replaceAll("-")); if (locale != Locale.ROOT && (locale.getLanguage() == null || locale.getLanguage().isEmpty())) { throw new IllegalArgumentException("Unable to resolve locale: " + value); } return locale; } LocaleConverter(); @Override Locale convert(final String value);  }