diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/LocaleTypeDescriptor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/LocaleTypeDescriptor.java index 646662ac00..e12f28312f 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/LocaleTypeDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/LocaleTypeDescriptor.java @@ -60,8 +60,8 @@ public class LocaleTypeDescriptor extends AbstractTypeDescriptor { public Locale fromString(String string) { StringTokenizer tokens = new StringTokenizer( string, "_" ); - String language = tokens.hasMoreTokens() ? tokens.nextToken() : ""; - String country = tokens.hasMoreTokens() ? tokens.nextToken() : ""; + String language = tokens.hasMoreTokens() && string.charAt(0) != '_' ? tokens.nextToken() : ""; + String country = tokens.hasMoreTokens() && string.charAt(string.indexOf(language) + language.length() + 1) != '_' ? tokens.nextToken() : ""; // Need to account for allowable '_' within the variant String variant = ""; String sep = "";