Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { private static String ordinal(int num) { String[] suffix = { "th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th" }; int m = num % 100; return String.valueOf(num) + suffix[(m > 10 && m < 20) ? 0 : (m % 10)]; } }