code: public static DateTimeFormatter createFormatterFromPatternString(
              String formatPattern, Locale locale) {
          DateTimeFormatter formatter = new DateTimeFormatterBuilder().parseLenient()
                  .parseCaseInsensitive().appendPattern(formatPattern)
                  .toFormatter(locale);
          return formatter;
      }
docs: createFormatterFromPatternString, This creates a DateTimeFormatter from the supplied pattern
  string and supplied locale. The pattern will be created to be "lenient" and "case
  insensitive", so it can be used for display or for user-friendly parsing. Information about
  creating a pattern string can be found in the DateTimeFormatter class Javadocs. @see
  <a href="https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html">
  The DateTimeFormatter Javadocs </a>
  
  Note: It is important to use the letter "u" (astronomical year) instead of "y" (year of era)
  when creating pattern strings for BCE dates. This is because the DatePicker uses ISO 8601,
  which specifies "Astronomical year numbering". (Additional details: The astronomical year
  "-1" and "1 BC" are not the same thing. Astronomical years are zero-based, and BC dates are
  one-based. Astronomical year "0", is the same year as "1 BC", and astronomical year "-1" is
  the same year as "2 BC", and so forth.)