]> source.dussan.org Git - poi.git/commitdiff
small big decimal refactor
authorPJ Fanning <fanningpj@apache.org>
Fri, 29 Apr 2022 12:32:54 +0000 (12:32 +0000)
committerPJ Fanning <fanningpj@apache.org>
Fri, 29 Apr 2022 12:32:54 +0000 (12:32 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1900377 13f79535-47bb-0310-9956-ffa450edef68

poi/src/main/java/org/apache/poi/ss/usermodel/DataFormatter.java

index c7725d3818e8e3b716f30571cb25296fd548151b..89c55ad4f76d992c7d66fc04d3e6f42b49597db7 100644 (file)
@@ -952,9 +952,8 @@ public class DataFormatter {
         }
         String formatted;
         try {
-            //see https://github.com/apache/poi/pull/321 -- but this sometimes fails as Double.toString
-            //can produce strings that can't be parsed by BigDecimal
-            formatted = numberFormat.format(new BigDecimal(Double.toString(d)));
+            //see https://github.com/apache/poi/pull/321 -- but this sometimes fails, thus the catch and retry
+            formatted = numberFormat.format(BigDecimal.valueOf(d));
         } catch (NumberFormatException nfe) {
             formatted = numberFormat.format(d);
         }