]> source.dussan.org Git - poi.git/commitdiff
Fix for DataFormatter on some JVMs
authorNick Burch <nick@apache.org>
Mon, 28 Jul 2008 16:41:47 +0000 (16:41 +0000)
committerNick Burch <nick@apache.org>
Mon, 28 Jul 2008 16:41:47 +0000 (16:41 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@680394 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/usermodel/HSSFDataFormatter.java

index c1701e22b39aef91b6a9fe018909d1e77051de69..e186cf73c357dccff79c413b831c2c24e9fc2f13 100644 (file)
@@ -202,10 +202,12 @@ public class HSSFDataFormatter {
                // remove color formatting if present
                String formatStr = sFormat.replaceAll("\\[[a-zA-Z]*\\]", "");
                
-               // try to extract special characters like currency
-               Matcher m = specialPatternGroup.matcher(formatStr);             
+               // Try to extract special characters like currency
+               // Need to re-create the matcher each time, as the string
+               //  will potentially change on each pass
+               Matcher m;
                try {
-                       while(m.find()) {
+                       while((m = specialPatternGroup.matcher(formatStr)).find()) {
                                String match = m.group();
                                String symbol = match.substring(match.indexOf('$') + 1, match.indexOf('-'));
                                if (symbol.indexOf('$') > -1) {