Java Number Convert to numberToOrdinal(int i)

Here you can find the source of numberToOrdinal(int i)

Description

number To Ordinal

License

LGPL

Declaration

public static String numberToOrdinal(int i) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {
    private static final String[] ORDINAL_SUFFIXES = new String[] { "th", "st", "nd", "rd", "th", "th", "th", "th",
            "th", "th" };

    public static String numberToOrdinal(int i) {
        return i % 100 == 11 || i % 100 == 12 || i % 100 == 13 ? i + "th" : i + ORDINAL_SUFFIXES[i % 10];
    }//from w  w  w  .j a  va2  s .co m
}

Related

  1. NumberToCharacter(final Number value)
  2. numberToFormattedString(Double d)
  3. numberToJson(Number number)
  4. numberToMinterm(int num, int length, int index, boolean[] output)
  5. numberToPaddedHexString(int number, int size)
  6. numberToPrimitiveLong(Object o)
  7. NumberToReal(Object n)