Locales { public static Locale fromString(final String string) { if (string == null) { return null; } else { try { return new Locale.Builder().setLanguageTag(string).build(); } catch (final IllformedLocaleException ex) { return LocaleUtils.toLocale(string); } } } private  Locales(); static Locale fromString(final String string);  }
@Test public void testUnderscore() { for (Locale l : COMMON_LOCALES) { assertEquals(l, Locales.fromString(l.toString())); } }
@Test public void testHyphen() { for (Locale l : COMMON_LOCALES) { assertEquals(l, Locales.fromString(l.toLanguageTag())); } }
@Test public void testNull() { assertNull(Locales.fromString(null)); }