add trillion

This commit is contained in:
Looly 2024-01-02 13:33:16 +08:00
parent 5a3e1cd8f6
commit 9e426dd3a5
3 changed files with 11 additions and 1 deletions

View File

@ -30,7 +30,7 @@ public class NumberWordFormatter {
"FIFTEEN", "SIXTEEN", "SEVENTEEN", "EIGHTEEN", "NINETEEN"}; "FIFTEEN", "SIXTEEN", "SEVENTEEN", "EIGHTEEN", "NINETEEN"};
private static final String[] NUMBER_TEN = new String[]{"TEN", "TWENTY", "THIRTY", "FORTY", "FIFTY", "SIXTY", private static final String[] NUMBER_TEN = new String[]{"TEN", "TWENTY", "THIRTY", "FORTY", "FIFTY", "SIXTY",
"SEVENTY", "EIGHTY", "NINETY"}; "SEVENTY", "EIGHTY", "NINETY"};
private static final String[] NUMBER_MORE = new String[]{"", "THOUSAND", "MILLION", "BILLION"}; private static final String[] NUMBER_MORE = new String[]{"", "THOUSAND", "MILLION", "BILLION", "TRILLION"};
private static final String[] NUMBER_SUFFIX = new String[]{"k", "w", "", "m", "", "", "b", "", "", "t", "", "", "p", "", "", "e"}; private static final String[] NUMBER_SUFFIX = new String[]{"k", "w", "", "m", "", "", "b", "", "", "t", "", "", "p", "", "", "e"};

View File

@ -13,6 +13,7 @@
package org.dromara.hutool.core.codec; package org.dromara.hutool.core.codec;
import org.dromara.hutool.core.codec.binary.Base62; import org.dromara.hutool.core.codec.binary.Base62;
import org.dromara.hutool.core.lang.Console;
import org.dromara.hutool.core.util.RandomUtil; import org.dromara.hutool.core.util.RandomUtil;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -60,4 +61,10 @@ public class Base62Test {
final String decodeStr = Base62.decodeStrInverted(encode); final String decodeStr = Base62.decodeStrInverted(encode);
Assertions.assertEquals(a, decodeStr); Assertions.assertEquals(a, decodeStr);
} }
@Test
void encodeNumbersTest() {
final String encode = Base62.encode("181338494");
Assertions.assertEquals("HRmWh8NiFvYi", encode);
}
} }

View File

@ -24,6 +24,9 @@ public class NumberWordFormatTest {
final String format2 = NumberWordFormatter.format("2100.00"); final String format2 = NumberWordFormatter.format("2100.00");
Assertions.assertEquals("TWO THOUSAND ONE HUNDRED AND CENTS ONLY", format2); Assertions.assertEquals("TWO THOUSAND ONE HUNDRED AND CENTS ONLY", format2);
final String format3 = NumberWordFormatter.format("1234567890123.12");
Assertions.assertEquals("ONE TRILLION TWO HUNDRED AND THIRTY FOUR BILLION FIVE HUNDRED AND SIXTY SEVEN MILLION EIGHT HUNDRED AND NINETY THOUSAND ONE HUNDRED AND TWENTY THREE AND CENTS TWELVE ONLY", format3);
} }
@Test @Test