code: public static String withOrdinalIndicator(long i) {
      String ord;
      // Grab second to last digit
      int d = (int) (Math.abs(i) / Math.pow(10, 1)) % 10;
      if (d == 1) ord = "th"; //teen values all end in "th"
      else { // not a weird teen number
        d = (int) (Math.abs(i) / Math.pow(10, 0)) % 10;
        switch (d) {
          case 1: ord = "st"; break;
          case 2: ord = "nd"; break;
          case 3: ord = "rd"; break;
          default: ord = "th";
        }
      }
      return i+ord;
    }
docs: This method takes a number, and returns the
  string form of the number with the proper
  ordinal indicator attached (e.g. 1->1st, and 22->22nd)
  @param i - number to have ordinal indicator attached
  @return string form of number along with ordinal indicator as a suffix