NumberToText is an apex class that converts an integer into a text representation of that integer.
number | text |
---|---|
0 | zero |
1 | one |
-136 | negative one hundred thirty-six |
12489543 | twelve million four hundred eighty-nine thousand five hundred forty-three |
convert(value)
public static String convert(Integer value)
Converts any integer value to a lowercase text representation of that integer. Negative values are prepended with the word 'negative.' Values between 21-99 are hyphenated. E.g. twenty-one.
Integer value = 125;
Integer negativeValue = -125;
String result = NumberToText.convert(value);
String negativeResult = NumberToText.convert(negativeValue);
// result = 'one hundred twenty-five'
// negativeResult = 'negative one hundred twenty-five'