Here you can find the source of numberToOrdinal(int i)
public static String numberToOrdinal(int i)
//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 }