Question

3
Replies
92
Views
Karthik K Member since 2016 32 posts
PEGA
Posted: 2 years ago
Last activity: 2 years 6 months ago
Closed

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.

INPUTDAYOUTPUTDAY
20171130T000000.000 GMT5th Thursday of Nov20180104T000000.000 GMT1st Thursday of Jan
20171031T000000.000 GMT5th Tuesday of Oct20171205T000000.000 GMT1st Tuesday of Dec
20171030T000000.000 GMT5th Monday of Oct20171204T000000.000 GMT1st Monday of Dec
20170930T000000.000 GMT5th Saturday of Sept20171104T000000.000 GMT1st Saturday of Nov
20170830T000000.000 GMT5th Wednesday of Aug20171004T000000.000 GMT1st Wednesday of Oct
20170730T000000.000 GMT5th Sunday of July20170903T000000.000 GMT1st Sunday of Sept
INPUTDAYOUTPUTDAY
20171125T000000.000 GMT4th Saturday of nov20171223T000000.000 GMT4th Saturday of Dec
20171129T000000.000 GMT5th Wednesday of Nov20171227T000000.000 GMT4th Wednesday of Dec
20171029T000000.000 GMT5th Sunday of Oct20171126T000000.000 GMT4th Sunday of Nov
20171020T000000.000 GMT3rd Friday of Oct20171117T000000.000 GMT3rd Friday of Nov
20170929T000000.000 GMT5th Friday of Sept20171027T000000.000 GMT4th Friday of Oct
20170829T000000.000 GMT5th Tuesday of Aug20170926T000000.000 GMT4th Tuesday of Sept
Reporting
Moderation Team has archived post
Share this page LinkedIn