mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-08-18 20:38:02 +08:00
提交NumberChineseFormatter.formatSimple,用于将阿拉伯数字(支持正负整数)四舍五入后转换成中文节权位简洁计数单位,例如 -5_5555 =》 -5.56万
This commit is contained in:
@@ -175,6 +175,26 @@ public class NumberChineseFormatterTest {
|
||||
Assert.assertEquals("零点零伍", f1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void formatSimpleTest() {
|
||||
String f1 = NumberChineseFormatter.formatSimple(1_2345);
|
||||
Assert.assertEquals("1.23万", f1);
|
||||
f1 = NumberChineseFormatter.formatSimple(-5_5555);
|
||||
Assert.assertEquals("-5.56万", f1);
|
||||
f1 = NumberChineseFormatter.formatSimple(1_2345_6789);
|
||||
Assert.assertEquals("1.23亿", f1);
|
||||
f1 = NumberChineseFormatter.formatSimple(-5_5555_5555);
|
||||
Assert.assertEquals("-5.56亿", f1);
|
||||
f1 = NumberChineseFormatter.formatSimple(1_2345_6789_1011L);
|
||||
Assert.assertEquals("1.23万亿", f1);
|
||||
f1 = NumberChineseFormatter.formatSimple(-5_5555_5555_5555L);
|
||||
Assert.assertEquals("-5.56万亿", f1);
|
||||
f1 = NumberChineseFormatter.formatSimple(123);
|
||||
Assert.assertEquals("123", f1);
|
||||
f1 = NumberChineseFormatter.formatSimple(-123);
|
||||
Assert.assertEquals("-123", f1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void digitToChineseTest() {
|
||||
String digitToChinese = Convert.digitToChinese(12_4124_1241_2421.12);
|
||||
|
||||
Reference in New Issue
Block a user