ordinalSuffix static method
Computes ordinal suffix based on number
Implementation
static String ordinalSuffix(int day)
{
// CREDIT: http://www.javalobby.org/java/forums/t16906.html
int hundredRemainder = day % 100;
if (hundredRemainder >= 10 && hundredRemainder <= 20) {
day = 4;
}
// Not a teen number
var tenRemainder = day % 10;
switch (tenRemainder)
{
case 1:
return "st";
case 2:
return "nd";
case 3:
return "rd";
default:
return "th";
}
}