preload
Dez 18

You would like to know the spellout word from an integer? Use the ICU library from IBM.

1
2
3
4
import com.ibm.icu.text.RuleBasedNumberFormat;
// ...
int num = 100198
System.out.println(new RuleBasedNumberFormat(Locale.US, RuleBasedNumberFormat.SPELLOUT).format(number));

The result is: one hundred thousand, one hundred and ninety-eight
You can get the spellout of the number in other languages. Check Locale.GERMANY instead of Locale.US and you have: hunderttausendhundertachtundneunzig

Tagged with: