@Test public void testGetLocaleConstant() { assertEquals(Locale.US, getLocaleConstant("US")); assertNull(getLocaleConstant("UN")); assertEquals(Locale.ENGLISH, getLocaleConstant("ENGLISH")); assertEquals(Locale.CHINA, getLocaleConstant("CHINA")); assertNull(getLocaleConstant("")); assertNull(getLocaleConstant(null)); }
public static Locale getLocaleConstant(String localeConstant) { try { Field field = Locale.class.getField(localeConstant); if (field != null && field.getType().equals(Locale.class)) { return (Locale) field.get(null); } } catch (Exception e) { return null; } return null; }
LocaleUtil { public static Locale getLocaleConstant(String localeConstant) { try { Field field = Locale.class.getField(localeConstant); if (field != null && field.getType().equals(Locale.class)) { return (Locale) field.get(null); } } catch (Exception e) { return null; } return null; } }
LocaleUtil { public static Locale getLocaleConstant(String localeConstant) { try { Field field = Locale.class.getField(localeConstant); if (field != null && field.getType().equals(Locale.class)) { return (Locale) field.get(null); } } catch (Exception e) { return null; } return null; } private  LocaleUtil(); }
LocaleUtil { public static Locale getLocaleConstant(String localeConstant) { try { Field field = Locale.class.getField(localeConstant); if (field != null && field.getType().equals(Locale.class)) { return (Locale) field.get(null); } } catch (Exception e) { return null; } return null; } private  LocaleUtil(); static Locale getLocaleConstant(String localeConstant); static Locale createLocale(String localeString); static Locale getLocale(String localeString); }
LocaleUtil { public static Locale getLocaleConstant(String localeConstant) { try { Field field = Locale.class.getField(localeConstant); if (field != null && field.getType().equals(Locale.class)) { return (Locale) field.get(null); } } catch (Exception e) { return null; } return null; } private  LocaleUtil(); static Locale getLocaleConstant(String localeConstant); static Locale createLocale(String localeString); static Locale getLocale(String localeString);  }