Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions common/src/main/java/com/genexus/LocalUtil.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.genexus;

import java.math.RoundingMode;
import java.util.*;
import java.text.*;

Expand Down Expand Up @@ -1713,6 +1714,7 @@ private String formatBigDecimal(java.math.BigDecimal value, String picture, Numb
{
DecimalFormat df = (DecimalFormat) numberFormat;
df.applyPattern(pictureToNumberFormat(withoutSuffixPicture));
df.setRoundingMode(RoundingMode.HALF_UP);
if ( CommonUtil.in(picture, '.') || CommonUtil.in(picture, ','))
{
formatted = alignAndPad(df.format(value), '0', withoutSuffixPicture, floating, numberFormat, originalPicture);
Expand Down
7 changes: 7 additions & 0 deletions java/src/test/java/com/genexus/TestCommonUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,13 @@ public void testFormat() {
result = ui.getLocalUtil().format(bigDecimalValue, picture);
Assert.assertEquals(expectedResult, result);

bigDecimalValue = new BigDecimal(2.5);
picture = "Z,ZZZ,ZZZ,ZZZ,ZZZ,ZZ9";
expectedResult = " 3";

result = ui.getLocalUtil().format(bigDecimalValue, picture);
Assert.assertEquals(expectedResult, result);

bigDecimalValue = new BigDecimal(-12.5);
picture = "$Z9.9";
expectedResult = "-$12.5";
Expand Down
Loading