Skip to content

Instantly share code, notes, and snippets.

@SeanPONeil
Created August 15, 2012 18:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SeanPONeil/3362100 to your computer and use it in GitHub Desktop.
Save SeanPONeil/3362100 to your computer and use it in GitHub Desktop.
add a suffix to a date
static String getDayOfMonthSuffix(final int n) {
if (n >= 11 && n <= 13) {
return "th";
}
switch (n % 10) {
case 1: return "st";
case 2: return "nd";
case 3: return "rd";
default: return "th";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment