Affects: 5.3.18

org.springframework.beans.propertyeditors.LocaleEditor should accept BCP 47 language tags too, like org.springframework.core.convert.support.StringToLocaleConverter does.

LocaleEditor uses StringUtils.parseLocaleString(text) that does not accept the language tag string. While the StringToLocaleConverter uses StringUtils.parseLocale(source) which works with language tags well.

Comment From: sbrannen

As discussed within the team, the current behavior is intentional since LocaleEditor is two-way by design: String-to-Locale and Locale-to-String, and only StringUtils.parseLocaleString() provides that consistent two-way behavior which is necessary for a PropertyEditor implementation.

In light of that, we are closing this issue.

Comment From: foal

Hmm... I'm not sure that is the correct solution. May be better to use BCP 47 language tags to represent the Java Locale as a string?

Comment From: foal

From Java doc of java.util.Locale.toString()

     * <p>This behavior is designed to support debugging and to be compatible with
     * previous uses of {@code toString} that expected language, country, and variant
     * fields only.  To represent a Locale as a String for interchange purposes, use
     * {@link #toLanguageTag}.