Inspired by the following posts
- Get the first Monday of a month
- Java: How do I get the date of x day in a month ( e.g. Third Monday in February 2012)
I need a function that returns the ordinal position for a given day in the month, for example:
01/01/1970 = 1 because it's the first Thursday in January, 1970
02/01/1970 = 1 because it's the first Friday in January, 1970
19/01/1970 = 3 because it's the third Monday in January, 1970
31/01/1970 = 5 because it's the fifth Saturday in January, 1970
What have I tried? - Nothing...I don't even know where to start; the Java 8 date/time API is pretty new to me.
Ideally I want a function with this signature:
public int getOrdinalPosition(TemporalAccessor temporal) {
...
}