You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And probably Locale…
Current Locale conversion is quite bad.
How about:
.withConverter(Locale.class, 101, s->{
if (s == null || s.isBlank()){
returnnull;
} elseif (found(s.indexOf('-'))){
returnLocale.forLanguageTag(trim(s));// de-DE
} else {// uses Guava, because it is a copy-paste of real code. Can be replaced with String.splitList<String> elements = Splitter.on('_').limit(3).trimResults().splitToList(s);
returnelements.size() == 1 ? newLocale(elements.get(0)) // de
: elements.size() == 2 ? newLocale(elements.get(0), elements.get(1)) // de_DE
: newLocale(elements.get(0), elements.get(1), elements.get(2));
}
})
We don't provide a specific Locale converter. In cases where there isn't one, an implicit Converter is determined by a lookup of static methods of,valueOf,parse, and String constructor (which matches how a Locale is converted).
This may be inconvenient in some cases, but it does cover a big spectrum of combinations. Feel free to provide a PR to improve it. Thank you!
The text was updated successfully, but these errors were encountered: