@Test public void testFromString() throws Exception { Locale locale = converter.fromString("fr"); assertThat(locale).isEqualTo(Locale.FRENCH); locale = converter.fromString("fr-FR"); assertThat(locale).isEqualTo(Locale.FRANCE); locale = converter.fromString("fr_CA"); assertThat(locale).isEqualTo(Locale.CANADA_FRENCH); locale = converter.fromString(""); assertThat(locale).isEqualTo(new Locale("", "","")); locale = converter.fromString(null); assertThat(locale).isEqualTo(new Locale("", "","")); }
@Override public Locale fromString(String input) throws IllegalArgumentException { if (!Strings.isNullOrEmpty(input)) { return Locale.forLanguageTag(input.replace("_", "-")); } return InternationalizationService.DEFAULT_LOCALE; }
LocaleParameterConverter implements ParameterConverter<Locale> { @Override public Locale fromString(String input) throws IllegalArgumentException { if (!Strings.isNullOrEmpty(input)) { return Locale.forLanguageTag(input.replace("_", "-")); } return InternationalizationService.DEFAULT_LOCALE; } }
LocaleParameterConverter implements ParameterConverter<Locale> { @Override public Locale fromString(String input) throws IllegalArgumentException { if (!Strings.isNullOrEmpty(input)) { return Locale.forLanguageTag(input.replace("_", "-")); } return InternationalizationService.DEFAULT_LOCALE; }  }
LocaleParameterConverter implements ParameterConverter<Locale> { @Override public Locale fromString(String input) throws IllegalArgumentException { if (!Strings.isNullOrEmpty(input)) { return Locale.forLanguageTag(input.replace("_", "-")); } return InternationalizationService.DEFAULT_LOCALE; }  @Override Locale fromString(String input); @Override Class<Locale> getType(); }
LocaleParameterConverter implements ParameterConverter<Locale> { @Override public Locale fromString(String input) throws IllegalArgumentException { if (!Strings.isNullOrEmpty(input)) { return Locale.forLanguageTag(input.replace("_", "-")); } return InternationalizationService.DEFAULT_LOCALE; }  @Override Locale fromString(String input); @Override Class<Locale> getType();  }