ChronologyParameterManager { public static Locale guessLocaleByEra(String value) { if (StringUtils.isEmpty(value)) { return DEFAULT_LOCALE; } int indexOf = value.indexOf(' '); if (indexOf != -1) { initMapIfNeeded(); String era = value.substring(indexOf + 1, value.length()); Locale locale = localeEraMap.get(era); if (locale != null) { return locale; } } return DEFAULT_LOCALE; } private  ChronologyParameterManager(); static Locale guessLocaleByEra(String value); static DateTimeFormatter getDateTimeFormatterWithChronology(String pattern, Locale locale);  }
@Test public void testGuessLocaleByEra() { assertEquals(Locale.US, ChronologyParameterManager.guessLocaleByEra("2017-05-18 AD")); assertEquals(Locale.US, ChronologyParameterManager.guessLocaleByEra("")); assertEquals(Locale.US, ChronologyParameterManager.guessLocaleByEra("2017-05-18 ABC")); assertEquals(Locale.US, ChronologyParameterManager.guessLocaleByEra("2017-05-18")); assertEquals(Locale.TRADITIONAL_CHINESE, ChronologyParameterManager.guessLocaleByEra("0106-05-18 民國")); assertEquals(Locale.TRADITIONAL_CHINESE, ChronologyParameterManager.guessLocaleByEra("6625-11-12 民國前")); assertEquals(Locale.JAPANESE, ChronologyParameterManager.guessLocaleByEra("0006-01-01 明治")); assertEquals(Locale.JAPANESE, ChronologyParameterManager.guessLocaleByEra("0029-05-18 平成")); assertEquals(Locale.JAPANESE, ChronologyParameterManager.guessLocaleByEra("0045-01-01 昭和")); assertEquals(Locale.JAPANESE, ChronologyParameterManager.guessLocaleByEra("0014-05-30 大正")); assertEquals(new Locale("ar"), ChronologyParameterManager.guessLocaleByEra("1438-08-22 هـ")); assertEquals(new Locale("th"), ChronologyParameterManager.guessLocaleByEra("4171-11-12 ปีก่อนคริสต์กาลที่")); assertEquals(new Locale("th"), ChronologyParameterManager.guessLocaleByEra("2560-05-18 พ.ศ.")); }