handlebars/src/main/java/com/github/jknack/handlebars/internal/Locales.java
public static Locale fromString(final String string) {
    if (string == null) {
      return null;
    } else {
      try {
        /*
         *  prefer https://en.wikipedia.org/wiki/IETF_language_tag
         *  (only Locale.Builder throws exception for illegal format)
         */
        return new Locale.Builder().setLanguageTag(string).build();
      } catch (final IllformedLocaleException ex) {
        // use fallback
        return LocaleUtils.toLocale(string);
      }
    }
  }
/**
   * <p>Converts {@link String}s to {@link Locale}s. Supports both
   * <a href="https://en.wikipedia.org/wiki/IETF_language_tag">IETF language tags</a>
   * using hyphens (e.g. &quot;de-AT&quot;) and the Java format using underscores
   * (e.g. &quot;de_AT&quot;).</p>
   *
   * @param string the local string either in IETF or Java format
   * @return The matching Locale
   */
Converts  Strings to  Locales. Supports both
IETF language tags
using hyphens  and the Java format using underscores
.

@param string the local string either in IETF or Java format
@return The matching Locale
Converts Strings to Locales . Supports both IETF language tags using hyphens and the Java format using underscores . @param string the local string either in IETF or Java format @return The matching Locale
public static Locale fromString(final String string) {
    if (string == null) {
      return null;
    } else {
      try {
        /*
         *  prefer https://en.wikipedia.org/wiki/IETF_language_tag
         *  (only Locale.Builder throws exception for illegal format)
         */
        return new Locale.Builder().setLanguageTag(string).build();
      } catch (final IllformedLocaleException ex) {
        return LocaleUtils.toLocale(string);
      }
    }
  }
public static Locale fromString ( final String string ) { if ( string == null ) { return null ; } else { try { /*
         *  prefer https://en.wikipedia.org/wiki/IETF_language_tag
         *  (only Locale.Builder throws exception for illegal format)
         */ return new Locale . Builder ( ) . setLanguageTag ( string ) . build ( ) ; } catch ( final IllformedLocaleException ex ) { return LocaleUtils . toLocale ( string ) ; } } }
<p>Converts {@link String}s to {@link Locale}s. Supports both
 <a href="https://en.wikipedia.org/wiki/IETF_language_tag">IETF language tags</a>
 using hyphens (e.g.
<p > Converts { @link String } s to { @link Locale } s . Supports both <a href = " https : // en . wikipedia . org / wiki / IETF_language_tag " > IETF language tags< / a > using hyphens ( e . g .
// use fallback