mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
修复Convert.digitToChinese(0)输出金额无元整问题
This commit is contained in:
parent
8ae3a87174
commit
4bb0a445c4
@ -2,7 +2,7 @@
|
||||
# 🚀Changelog
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
# 5.8.30(2024-07-30)
|
||||
# 5.8.30(2024-07-31)
|
||||
|
||||
### 🐣新特性
|
||||
* 【core 】 Converter转换规则变更,空对象、空值转为Bean时,创建默认对象,而非null(issue#3649@Github)
|
||||
@ -22,6 +22,7 @@
|
||||
* 【core 】 修复FileUtil.file末尾换行符导致路径判断错误的问题(issue#IAB65V@Gitee)
|
||||
* 【core 】 修复FileTypeUtil.getType空指针问题(issue#IAD5JM@Gitee)
|
||||
* 【core 】 修复IdcardUtil.isValidHKCard校验问题(issue#IAFOLI@Gitee)
|
||||
* 【core 】 修复Convert.digitToChinese(0)输出金额无`元整问题`(issue#3662@Github)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
# 5.8.29(2024-07-03)
|
||||
|
@ -1030,7 +1030,7 @@ public class Convert {
|
||||
*/
|
||||
public static String digitToChinese(Number n) {
|
||||
if (null == n) {
|
||||
return "零";
|
||||
n = 0;
|
||||
}
|
||||
return NumberChineseFormatter.format(n.doubleValue(), true, true);
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ public class NumberChineseFormatter {
|
||||
*/
|
||||
public static String format(double amount, boolean isUseTraditional, boolean isMoneyMode, String negativeName, String unitName) {
|
||||
if (0 == amount) {
|
||||
return "零";
|
||||
return isMoneyMode ? "零元整" : "零";
|
||||
}
|
||||
Assert.checkBetween(amount, -99_9999_9999_9999.99, 99_9999_9999_9999.99,
|
||||
"Number support only: (-99999999999999.99 ~ 99999999999999.99)!");
|
||||
|
@ -435,4 +435,12 @@ public class ConvertTest {
|
||||
Assert.assertEquals(12, s);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void issue3662Test() {
|
||||
String s = Convert.digitToChinese(0);
|
||||
Assert.assertEquals("零元整", s);
|
||||
|
||||
s = Convert.digitToChinese(null);
|
||||
Assert.assertEquals("零元整", s);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user