EG:
- 1 -> first
- 2 -> second
- 3 -> third
and so on.
I looked at ICU4J, but it only has the option to convert to ordinal numbers, eg:
- 1 -> 1st
- 2 -> 2nd
- 3 -> 3rd
But this is not what I want.
EG:
and so on.
I looked at ICU4J, but it only has the option to convert to ordinal numbers, eg:
But this is not what I want.
I would just do it with a custom Enum. Multiple ways you could do it, so this is just a rough example to PROVE the point.
import java.util.*;
import java.util.stream.*;
public class HelloWorld{
enum PhrasedNumber {
Zeroth, First, Second, Third, Fourth;
static List<String> enumNames = Stream.of(PhrasedNumber.values())
.map(PhrasedNumber::name)
.collect(Collectors.toList());
}
public static void main(String []args){
String phrase = PhrasedNumber.enumNames.get(2);
System.out.println("Hello World " + phrase);
}
}
The output looks like this:
Hello World Second