提交NumberChineseFormatter.formatSimple,用于将阿拉伯数字(支持正负整数)四舍五入后转换成中文节权位简洁计数单位,例如 -5_5555 =》 -5.56万

This commit is contained in:
VampireAchao
2022-02-10 21:09:26 +08:00
parent 7116177225
commit b5dfc8b639
2 changed files with 42 additions and 0 deletions

View File

@@ -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);