mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-08-18 20:38:02 +08:00
Excel07SaxReader中,对于小数类型,增加精度判断(issue#IB0EJ9@Gitee)
This commit is contained in:
25
hutool-json/src/test/java/cn/hutool/json/Issue3790Test.java
Normal file
25
hutool-json/src/test/java/cn/hutool/json/Issue3790Test.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package cn.hutool.json;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
public class Issue3790Test {
|
||||
@Test
|
||||
void bigDecimalToStringTest() {
|
||||
BigDecimal bigDecimal = new BigDecimal("0.01");
|
||||
bigDecimal = bigDecimal.setScale(4, RoundingMode.HALF_UP);
|
||||
|
||||
Dto dto = new Dto();
|
||||
dto.remain = bigDecimal;
|
||||
|
||||
final String jsonStr = JSONUtil.toJsonStr(dto, JSONConfig.create().setStripTrailingZeros(false));
|
||||
Assertions.assertEquals("{\"remain\":0.0100}", jsonStr);
|
||||
}
|
||||
|
||||
static class Dto {
|
||||
public BigDecimal remain;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user