Skip to content

Commit

Permalink
Fix grouping commas forcing leading zeroes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tisawesomeness committed Sep 19, 2023
1 parent 049d05d commit 59729a1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public String format(double d) {
return addApproxSymbolIfNotExact(scientificNotationFormat, d).toLowerCase(Locale.ROOT);
}
private String createPattern(boolean scientificNotation) {
String integralPart = includeGroupingCommas ? "0,000" : "0";
String integralPart = includeGroupingCommas ? "#,##0" : "0";
String mantissaPart = scientificNotation ? "E0" : "";
return String.format("%s.0%s", integralPart, mantissaPart);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ public void testFormatFractionDigits(int minDigits, int maxDigits, double input,
@ParameterizedTest
@CsvSource({
"1234567.0, '1,234,567'",
"1234567.89012, '1,234,567.89012'"
"1234567.89012, '1,234,567.89012'",
"12.0, '12'",
"1000000, '1,000,000'",
"0.0, '0'"
})
public void testFormatGrouping(double input, String expected) {
HumanDecimalFormat format = HumanDecimalFormat.builder()
Expand Down

0 comments on commit 59729a1

Please sign in to comment.