Handle differences between JDK1.3 and JDK1.4
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@307279 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a05cd12b23
commit
cfd9081647
|
@ -70,11 +70,15 @@ public class LocaleUtils {
|
|||
* locale object from it.</p>
|
||||
*
|
||||
* <pre>
|
||||
* LocaleUtils.toLocale("en") = new Locale("en", "")
|
||||
* LocaleUtils.toLocale("en_GB") = new Locale("en", "GB")
|
||||
* LocaleUtils.toLocale("en_GB_xxx") = new Locale("en", "GB", "xxx")
|
||||
* LocaleUtils.toLocale("en") = new Locale("en", "")
|
||||
* LocaleUtils.toLocale("en_GB") = new Locale("en", "GB")
|
||||
* LocaleUtils.toLocale("en_GB_xxx") = new Locale("en", "GB", "xxx") (#)
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* <p>(#) The behaviour of the JDK variant constructor changed between JDK1.3 and JDK1.4.
|
||||
* In JDK1.3, the constructor upper cases the variant, in JDK1.4, it doesn't.
|
||||
* Thus, the result from getVariant() may vary depending on your JDK.</p>
|
||||
*
|
||||
* <p>This method validates the input strictly.
|
||||
* The language code must be lowercase.
|
||||
* The country code must be uppercase.
|
||||
|
|
|
@ -220,9 +220,16 @@ public class LocaleUtilsTest extends TestCase {
|
|||
* Test toLocale() method.
|
||||
*/
|
||||
public void testToLocale_3Part() {
|
||||
assertValidToLocale("us_EN_a", "us", "EN", "a");
|
||||
assertValidToLocale("us_EN_A", "us", "EN", "A");
|
||||
assertValidToLocale("us_EN_SFsafdFDsdfF", "us", "EN", "SFsafdFDsdfF");
|
||||
// this isn't pretty, but was caused by a jdk bug it seems
|
||||
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4210525
|
||||
if (SystemUtils.isJavaVersionAtLeast(1.4f)) {
|
||||
assertValidToLocale("us_EN_a", "us", "EN", "a");
|
||||
assertValidToLocale("us_EN_SFsafdFDsdfF", "us", "EN", "SFsafdFDsdfF");
|
||||
} else {
|
||||
assertValidToLocale("us_EN_a", "us", "EN", "A");
|
||||
assertValidToLocale("us_EN_SFsafdFDsdfF", "us", "EN", "SFSAFDFDSDFF");
|
||||
}
|
||||
|
||||
try {
|
||||
LocaleUtils.toLocale("us_EN-a");
|
||||
|
@ -272,7 +279,7 @@ public class LocaleUtilsTest extends TestCase {
|
|||
new Locale[] {
|
||||
LOCALE_EN_US_ZZZZ,
|
||||
LOCALE_EN_US,
|
||||
new Locale("en", "")});
|
||||
LOCALE_EN});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue