public static DateTimeFormatter generateDefaultFormatterBCE ( Locale pickerLocale ) { // This is verified to work for the following locale languages: // en, de, fr, pt, ru, it, nl, es, pl, da, ro, sv, zh. String displayFormatterBCPattern = DateTimeFormatterBuilder . getLocalizedDateTimePattern ( FormatStyle . LONG , null , IsoChronology . INSTANCE , pickerLocale ) ; displayFormatterBCPattern = displayFormatterBCPattern . replace ( "y" , "u" ) ; // Note: We could have used DateUtilities.createFormatterFromPatternString(), which should // have the same formatter options as this line. We kept this code independent in case // anyone ever mistakenly changes that utility function. DateTimeFormatter displayFormatterBC = new DateTimeFormatterBuilder ( ) . parseLenient ( ) . parseCaseInsensitive ( ) . appendPattern ( displayFormatterBCPattern ) . toFormatter ( pickerLocale ) ; // Get the local language as a string. String language = pickerLocale . getLanguage ( ) ; // Override the format for the turkish locale to remove the name of the weekday. if ( "tr" . equals ( language ) ) { displayFormatterBC = PickerUtilities . createFormatterFromPatternString ( "dd MMMM uuuu" , pickerLocale ) ; } return displayFormatterBC ; }
generateDefaultFormatterBCE This returns a default formatter for the specified locale that can be used for displaying or parsing BC dates . The formatter is generated from the default FormatStyle . LONG formatter in the specified locale . The resulting format is intended to be nearly identical to the default formatter used for AD dates .