small big decimal refactor

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1900377 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2022-04-29 12:32:54 +00:00
parent 88441c4354
commit 5dd1ded85f
1 changed files with 2 additions and 3 deletions

View 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);
}