1

I need to convert a number to its rank.

1 -> "First"

2 -> "Second"

3 -> "Third"

  • %simplified (this gives 'one', 'two', 'three' etc.)
  • %default (this gives 'one', 'two', 'three' etc.)
  • %main (this gives 1st, 2nd, 3rd etc.)

The code in first link throws an exception (for rule set "%simplified-ordinal") that it is unknown 'rule-set'

The question is already asked on SO (link below) and tried one of its solution but did not work.

Links I've already referred to are:

I believe there is some 'rule-set' I need to pass to get what I'm looking for, but I'm not able to find it.

Community
  • 1
  • 1
rumit patel
  • 1,891
  • 5
  • 23
  • 28
  • What about using enums? it may solve the "First"=1 "Second"=2 if you define it correctly. – Rotem Dec 28 '16 at 22:35
  • 1
    The solution of JFK on that first link didn't work for you? ``` RuleBasedNumberFormat nf = new RuleBasedNumberFormat(Locale.UK, RuleBasedNumberFormat.SPELLOUT); for(int i = 0; i <= 30; i++) { System.out.println(i + " -> "+nf.format(i, "%spellout-ordinal")); } ``` – Jochen Bedersdorfer Dec 29 '16 at 02:04

0 Answers0