ChronologyParameterManager { public static DateTimeFormatter getDateTimeFormatterWithChronology(String pattern, Locale locale) { DateTimeFormatter formatter = new DateTimeFormatterBuilder() .parseCaseInsensitive() .appendPattern(pattern) .toFormatter(locale) .withResolverStyle(ResolverStyle.STRICT); if (Locale.JAPANESE.equals(locale)) { return formatter.withChronology(JapaneseChronology.INSTANCE); } else if (Locale.TRADITIONAL_CHINESE.equals(locale)) { return formatter.withChronology(MinguoChronology.INSTANCE); } else if ("ar".equals(locale.getLanguage())) { return formatter.withChronology(HijrahChronology.INSTANCE); } else if ("th".equals(locale.getLanguage())) { return formatter.withChronology(ThaiBuddhistChronology.INSTANCE).withLocale(locale); } return formatter; } private  ChronologyParameterManager(); static Locale guessLocaleByEra(String value); static DateTimeFormatter getDateTimeFormatterWithChronology(String pattern, Locale locale);  }
@Test public void testgetDateTimeFormatterWithChronology() { String pattern = "yyyy-MM-dd G"; Locale locale = Locale.JAPANESE; DateTimeFormatter dateTimeFormatter = ChronologyParameterManager.getDateTimeFormatterWithChronology(pattern, locale); assertEquals(JapaneseChronology.INSTANCE, dateTimeFormatter.getChronology()); locale = Locale.TAIWAN; dateTimeFormatter = ChronologyParameterManager.getDateTimeFormatterWithChronology(pattern, locale); assertEquals(MinguoChronology.INSTANCE, dateTimeFormatter.getChronology()); locale = new Locale("ar"); dateTimeFormatter = ChronologyParameterManager.getDateTimeFormatterWithChronology(pattern, locale); assertEquals(HijrahChronology.INSTANCE, dateTimeFormatter.getChronology()); locale = new Locale("th"); dateTimeFormatter = ChronologyParameterManager.getDateTimeFormatterWithChronology(pattern, locale); assertEquals(ThaiBuddhistChronology.INSTANCE, dateTimeFormatter.getChronology()); }