From 7270eb78790994fef8c42215bcd363d7c613a9d6 Mon Sep 17 00:00:00 2001 From: JET Date: Wed, 15 Dec 2010 15:18:43 -0700 Subject: [PATCH] Fixed behavior of Locale and implemented its toString(). --- classpath/java/util/Locale.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/classpath/java/util/Locale.java b/classpath/java/util/Locale.java index 8c756ff406..373506bdec 100644 --- a/classpath/java/util/Locale.java +++ b/classpath/java/util/Locale.java @@ -30,11 +30,11 @@ public class Locale { } public Locale(String language, String country) { - this(language, country, null); + this(language, country, ""); } public Locale(String language) { - this(language, null); + this(language, ""); } public String getLanguage() { @@ -52,4 +52,13 @@ public class Locale { public static Locale getDefault() { return DEFAULT; } + + public final String toString() { + boolean hasLanguage = language != ""; + boolean hasCountry = country != ""; + boolean hasVariant = variant != ""; + + if (!hasLanguage && !hasCountry) return ""; + return language + (hasCountry || hasVariant ? '_' + country : "") + (hasVariant ? '_' + variant : ""); + } }