groovy ordinal suffix (i.e. "1st" "2nd" "3rd"...etc)
Posted: 30 Aug 2021, 03:41
Sometimes I want to add an ordinal suffix to a title - most often in dates, but it can be in other fields.
I've played around with a few ways to do this, but not yet found an elegant way to do it in Groovy - but then I'm still a Groovy newbie
Specifically for dates, I found this pretty good summary of things that can be done:
https://rmr.fandom.com/wiki/Groovy_Date ... Formatting
But still no mention in there of ordinal suffix support in Groovy.
To give a specific example, let's say I have this in my format expression:
Which will output a date in the format "1 July 1978"
Can anyone suggest an elegant way in Groovy to change this to "1st July 1978"?
I've played around with a few ways to do this, but not yet found an elegant way to do it in Groovy - but then I'm still a Groovy newbie
Specifically for dates, I found this pretty good summary of things that can be done:
https://rmr.fandom.com/wiki/Groovy_Date ... Formatting
But still no mention in there of ordinal suffix support in Groovy.
To give a specific example, let's say I have this in my format expression:
Code: Select all
{airdate.format('d MMMM yyyy')}
Can anyone suggest an elegant way in Groovy to change this to "1st July 1978"?