This commit is contained in:
Looly
2022-01-19 09:25:05 +08:00
parent ee80e8c195
commit 9a88945386
3 changed files with 8 additions and 6 deletions

View File

@@ -165,10 +165,6 @@ 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){
// "十一"而非"一十一"
@@ -289,6 +285,11 @@ public class NumberChineseFormatter {
* @return 转换后的汉字
*/
private static String thousandToChinese(int amountPart, boolean isUseTraditional) {
if (amountPart == 0) {
// issue#I4R92H@Gitee
return String.valueOf(DIGITS[0]);
}
int temp = amountPart;
StringBuilder chineseStr = new StringBuilder();

View File

@@ -555,7 +555,7 @@ public class CalendarUtil {
result.append(NumberChineseFormatter.formatThousand(day, false));
result.append('日');
// 时分秒中零不需要替换
// 只替换年月日,时分秒中零不需要替换
String temp = result.toString().replace('零', '');
result.delete(0, result.length());
result.append(temp);