From 4b02bc72877150eab22ff3ab056785676714a0f3 Mon Sep 17 00:00:00 2001 From: tjh Date: Tue, 18 Jan 2022 15:39:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E4=B8=BA=E4=B8=AD=E6=96=87=E6=97=A5=E6=9C=9F=E6=97=B6?= =?UTF-8?q?=EF=BC=8C0=E8=A2=AB=E5=A4=84=E7=90=86=E4=B8=BA=E7=A9=BA?= =?UTF-8?q?=E4=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/hutool/core/convert/NumberChineseFormatter.java | 5 +++++ 1 file changed, 5 insertions(+) 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 afbb9d472..cacd13000 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 @@ -164,6 +164,11 @@ public class NumberChineseFormatter { */ public static String formatThousand(int amount, boolean isUseTraditional){ Assert.checkBetween(amount, -999, 999, "Number support only: (-999 ~ 999)!"); + + // thousandToChinese方法对0不处理,此处直接返回"零" + if (amount == 0) { + return String.valueOf(DIGITS[0]); + } final String chinese = thousandToChinese(amount, isUseTraditional); if(amount < 20 && amount > 10){ // "十一"而非"一十一"