summaryrefslogtreecommitdiff
path: root/java/text
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2008-07-07 15:07:15 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2008-07-07 15:07:15 +0000
commit7cc619591081162d81046b8a8bfb8367040f82cf (patch)
tree7673a9c67c56dffa09824a21ade4723ad974537a /java/text
parent0485d9699242e3c74c5fbca0cd25a33bc213a718 (diff)
downloadclasspath-7cc619591081162d81046b8a8bfb8367040f82cf.tar.gz
Support translating metazone names to standard zone names.
2008-07-07 Andrew John Hughes <gnu_andrew@member.fsf.org> * java/text/DateFormatSymbols.java: Use metazones to convert metazone names to standard Continent/City form. Also add hack to include GMT as a short name. * resource/java/text/metazones.properties: New properties file for mapping metazones to standard zone names.
Diffstat (limited to 'java/text')
-rw-r--r--java/text/DateFormatSymbols.java49
1 files changed, 47 insertions, 2 deletions
diff --git a/java/text/DateFormatSymbols.java b/java/text/DateFormatSymbols.java
index d5812140c..5e7a39ebe 100644
--- a/java/text/DateFormatSymbols.java
+++ b/java/text/DateFormatSymbols.java
@@ -40,12 +40,17 @@ package java.text;
import gnu.java.locale.LocaleHelper;
+import java.io.IOException;
+
import java.text.spi.DateFormatSymbolsProvider;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Locale;
+import java.util.Map;
import java.util.MissingResourceException;
+import java.util.Properties;
import java.util.ResourceBundle;
import java.util.ServiceLoader;
import java.util.TimeZone;
@@ -74,6 +79,27 @@ public class DateFormatSymbols implements java.io.Serializable, Cloneable
String[] weekdays;
/**
+ * The set of properties for obtaining the metazone data.
+ */
+ private static transient final Properties properties;
+
+ /**
+ * Reads in the properties.
+ */
+ static
+ {
+ properties = new Properties();
+ try
+ {
+ properties.load(DateFormatSymbols.class.getResourceAsStream("metazones.properties"));
+ }
+ catch (IOException exception)
+ {
+ System.out.println("Failed to load weeks resource: " + exception);
+ }
+ }
+
+ /**
* The timezone strings supplied by the runtime.
*/
private String[][] runtimeZoneStrings;
@@ -110,21 +136,40 @@ public class DateFormatSymbols implements java.io.Serializable, Cloneable
try
{
int index = 0;
+ String country = locale.getCountry();
+ Map<String,String[]> systemZones = new HashMap<String,String[]>();
String data = res.getString("zoneStrings");
String[] zones = data.split("\u00a9");
for (int a = 0; a < zones.length; ++a)
{
String[] strings = zones[a].split("\u00ae");
+ // Workaround for missing short GMT display name
+ // See http://www.unicode.org/cldr/bugs/locale-bugs/incoming?id=1885
+ if (strings[0].equals("GMT"))
+ strings[2] = "GMT";
+ String type = properties.getProperty(strings[0] + "." + country);
+ if (type == null)
+ type = properties.getProperty(strings[0] + ".DEFAULT");
+ if (type != null)
+ strings[0] = type;
if (strings.length < 5)
{
String[] newStrings = new String[5];
System.arraycopy(strings, 0, newStrings, 0, strings.length);
- for (int b = strings.length; a < newStrings.length; ++a)
+ for (int b = strings.length; b < newStrings.length; ++b)
newStrings[b] = "";
strings = newStrings;
}
- allZones.add(strings);
+ String[] existing = systemZones.get(strings[0]);
+ if (existing != null && existing.length > 1)
+ {
+ for (int b = 1; b < existing.length; ++b)
+ if (!existing[b].equals(""))
+ strings[b] = existing[b];
+ }
+ systemZones.put(strings[0], strings);
}
+ allZones.addAll(systemZones.values());
}
catch (MissingResourceException e)
{