addMonthsToSameDay : behaving different for 30 and 31 st Dates
addMonthsToSameDay function is behaving differently(as far as I think) for the 30 & 31 st of the months. Please, check the below table:
addMonthsToSameDay(java.lang.String theDate, int numOfMonths) |
For 30 & 31 st, Its skipping the immediate next month and giving a different output than expected.
Could you please answer, why its behaving differently for 30 & 31.
We are passing numOfMonths as 1.
addMonthsToSameDay function is behaving differently(as far as I think) for the 30 & 31 st of the months. Please, check the below table:
addMonthsToSameDay(java.lang.String theDate, int numOfMonths) |
For 30 & 31 st, Its skipping the immediate next month and giving a different output than expected.
Could you please answer, why its behaving differently for 30 & 31.
We are passing numOfMonths as 1.
INPUT | DAY | OUTPUT | DAY |
20171130T000000.000 GMT | 5th Thursday of Nov | 20180104T000000.000 GMT | 1st Thursday of Jan |
20171031T000000.000 GMT | 5th Tuesday of Oct | 20171205T000000.000 GMT | 1st Tuesday of Dec |
20171030T000000.000 GMT | 5th Monday of Oct | 20171204T000000.000 GMT | 1st Monday of Dec |
20170930T000000.000 GMT | 5th Saturday of Sept | 20171104T000000.000 GMT | 1st Saturday of Nov |
20170830T000000.000 GMT | 5th Wednesday of Aug | 20171004T000000.000 GMT | 1st Wednesday of Oct |
20170730T000000.000 GMT | 5th Sunday of July | 20170903T000000.000 GMT | 1st Sunday of Sept |
INPUT | DAY | OUTPUT | DAY |
20171125T000000.000 GMT | 4th Saturday of nov | 20171223T000000.000 GMT | 4th Saturday of Dec |
20171129T000000.000 GMT | 5th Wednesday of Nov | 20171227T000000.000 GMT | 4th Wednesday of Dec |
20171029T000000.000 GMT | 5th Sunday of Oct | 20171126T000000.000 GMT | 4th Sunday of Nov |
20171020T000000.000 GMT | 3rd Friday of Oct | 20171117T000000.000 GMT | 3rd Friday of Nov |
20170929T000000.000 GMT | 5th Friday of Sept | 20171027T000000.000 GMT | 4th Friday of Oct |
20170829T000000.000 GMT | 5th Tuesday of Aug | 20170926T000000.000 GMT | 4th Tuesday of Sept |