diff --git a/CHANGELOG.md b/CHANGELOG.md index 54b8d0b62..c70980eb2 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ # 🚀Changelog ------------------------------------------------------------------------------------------------------------- -# 5.8.28(2024-04-20) +# 5.8.28(2024-04-21) ### 🐣新特性 * 【core 】 修正XmlUtil的omitXmlDeclaration描述注释(issue#I9CPC7@Gitee) @@ -11,6 +11,7 @@ * 【extra 】 增加设置验证码大小和针对alias注释(pr#3533@Github) * 【json 】 JSONConfig增加setWriteLongAsString可选是否将Long写出为String类型(issue#3541@Github) * 【cache 】 CacheUtil.newTimedCache增加有schedulePruneDelay参数的重载方法(issue#I9HO25@Gitee) +* 【core 】 NumberChineseFormatter提供阿拉伯转中文支持多位小数的方法(pr#3552@Github) ### 🐞Bug修复 * 【http 】 修复HttpUtil.urlWithFormUrlEncoded方法重复编码问题(issue#3536@Github) diff --git a/hutool-core/src/main/java/cn/hutool/core/convert/NumberChineseFormatter.java b/hutool-core/src/main/java/cn/hutool/core/convert/NumberChineseFormatter.java index c9a45d90c..40e38b2eb 100644 --- a/hutool-core/src/main/java/cn/hutool/core/convert/NumberChineseFormatter.java +++ b/hutool-core/src/main/java/cn/hutool/core/convert/NumberChineseFormatter.java @@ -51,6 +51,7 @@ public class NumberChineseFormatter { * 口语化映射 */ private static final Map COLLOQUIAL_WORDS = new HashMap() { + private static final long serialVersionUID = 1L; { put("一十", "十"); put("一拾", "拾"); @@ -244,6 +245,7 @@ public class NumberChineseFormatter { * @param isUseTraditional 是否使用繁体 * @param isUseColloquial 是否使用口语化(e.g. 一十 -> 十) * @return 中文 + * @since 5.8.28 */ public static String format(BigDecimal amount, boolean isUseTraditional, boolean isUseColloquial) { String formatAmount; diff --git a/hutool-core/src/test/java/cn/hutool/core/convert/NumberChineseFormatterTest.java b/hutool-core/src/test/java/cn/hutool/core/convert/NumberChineseFormatterTest.java index b55bbcf6e..196b60c22 100644 --- a/hutool-core/src/test/java/cn/hutool/core/convert/NumberChineseFormatterTest.java +++ b/hutool-core/src/test/java/cn/hutool/core/convert/NumberChineseFormatterTest.java @@ -3,6 +3,8 @@ package cn.hutool.core.convert; import org.junit.Assert; import org.junit.Test; +import java.math.BigDecimal; + public class NumberChineseFormatterTest { @Test @@ -342,4 +344,10 @@ public class NumberChineseFormatterTest { format = NumberChineseFormatter.format(1.02, false, false); Assert.assertEquals("一点零二", format); } + + @Test + public void dotTest() { + final String format = NumberChineseFormatter.format(new BigDecimal("3.1415926"), false, false); + Assert.assertEquals("三点一四一五九二六", format); + } }