summaryrefslogtreecommitdiffstats
path: root/icu/src/main/java
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2010-01-11 10:55:28 -0800
committerElliott Hughes <enh@google.com>2010-01-11 10:55:28 -0800
commit0b18d1e6c8f550fa653d5f12a04f9d3a49a72cb6 (patch)
tree5ad338c2303a4ee144e5742379c7fb593dca83b4 /icu/src/main/java
parent2343dd8e57d1b1e3e759d86ecf01f53cce43c2fd (diff)
downloadlibcore-0b18d1e6c8f550fa653d5f12a04f9d3a49a72cb6.zip
libcore-0b18d1e6c8f550fa653d5f12a04f9d3a49a72cb6.tar.gz
libcore-0b18d1e6c8f550fa653d5f12a04f9d3a49a72cb6.tar.bz2
Support non-default negative patterns in NumberFormat.getIntegerInstance.
Spotted while rewriting the associated JNI recently.
Diffstat (limited to 'icu/src/main/java')
-rw-r--r--icu/src/main/java/com/ibm/icu4jni/util/Resources.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/icu/src/main/java/com/ibm/icu4jni/util/Resources.java b/icu/src/main/java/com/ibm/icu4jni/util/Resources.java
index 8f09029..efc55d1 100644
--- a/icu/src/main/java/com/ibm/icu4jni/util/Resources.java
+++ b/icu/src/main/java/com/ibm/icu4jni/util/Resources.java
@@ -343,8 +343,13 @@ public class Resources {
localeData.fullTimeFormat = localeData.fullTimeFormat.replace('v', 'z');
}
if (localeData.numberPattern != null) {
- String numberPattern = localeData.numberPattern;
- localeData.integerPattern = numberPattern.substring(0, numberPattern.indexOf('.'));
+ // The number pattern might contain positive and negative subpatterns. Arabic, for
+ // example, might look like "#,##0.###;#,##0.###-" because the minus sign should be
+ // written last. Macedonian supposedly looks something like "#,##0.###;(#,##0.###)".
+ // (The negative subpattern is optional, though, and not present in most locales.)
+ // By only swallowing '#'es and ','s after the '.', we ensure that we don't
+ // accidentally eat too much.
+ localeData.integerPattern = localeData.numberPattern.replaceAll("\\.[#,]*", "");
}
return localeData;
}