Improved: Usage of factory method or Builder pattern for Locale object creation and usage.

Thanks Yash Sharma for your contribution. (OFBIZ-9488)

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1812350 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Deepak Dixit
2017-10-17 06:06:56 +00:00
parent 1620e4e0ca
commit 829856e5f6
@@ -523,12 +523,12 @@ public final class UtilMisc {
Locale locale = null;
if (localeString.length() == 2) {
// two letter language code
locale = new Locale(localeString);
locale = new Locale.Builder().setLanguage(localeString).build();
} else if (localeString.length() == 5) {
// positions 0-1 language, 3-4 are country
String language = localeString.substring(0, 2);
String country = localeString.substring(3, 5);
locale = new Locale(language, country);
locale = new Locale.Builder().setLanguage(language).setRegion(country).build();
} else if (localeString.length() > 6) {
// positions 0-1 language, 3-4 are country, 6 and on are special extensions
String language = localeString.substring(0, 2);