Skip to content

Commit c350080

Browse files
committed
StringUtils.parseLocaleString parses variant correctly when variant contains country code
This commit also includes a JUnit 4 style revision of StringUtilsTests and ObjectUtilsTests. Issue: SPR-11806 (cherry picked from commit 295a6ae)
1 parent 6b9738f commit c350080

File tree

3 files changed

+219
-63
lines changed

3 files changed

+219
-63
lines changed

spring-core/src/main/java/org/springframework/util/StringUtils.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -51,7 +51,6 @@
5151
* @author Rick Evans
5252
* @author Arjen Poutsma
5353
* @since 16 April 2001
54-
* @see org.apache.commons.lang.StringUtils
5554
*/
5655
public abstract class StringUtils {
5756

@@ -696,7 +695,7 @@ public static Locale parseLocaleString(String localeString) {
696695
if (parts.length > 2) {
697696
// There is definitely a variant, and it is everything after the country
698697
// code sans the separator between the country code and the variant.
699-
int endIndexOfCountryCode = localeString.lastIndexOf(country) + country.length();
698+
int endIndexOfCountryCode = localeString.indexOf(country, language.length()) + country.length();
700699
// Strip off any leading '_' and whitespace, what's left is the variant.
701700
variant = trimLeadingWhitespace(localeString.substring(endIndexOfCountryCode));
702701
if (variant.startsWith("_")) {

0 commit comments

Comments
 (0)