That is either the result of an odd implementation choice or an oversight. It is consistent in adding the days into the next month, even into the next year. It also subtracts days into the previous month, even negative numbers get processed. Some tests on https://mydemoversion8-sandbox.mxapps.io/p/ff/ParseDateTime show these results:
The last example even adds one hour for daylight saving time.
And it takes in big numbers too:
Your “creative” solution is actually very good. As far as I can see it covers all unexpected results.
I would consider this a bug. Did some testing. In 8.10 it would give a fault when parsing this string (I did not have 8.9 on my machine). But in later versions it indeed gave this result. I also tested it in Mx7.23.7 and it gave the same result. It seems you found a very peculiar bug here. FIle a bug report to Mendix because this is not correct in my opinion.
Regards,
Ronald
(The issue is still open at support, I just asked for an update on the topic.)
(The issue is still open at support, I just asked for an update on the topic.)
last update today:
This behavior corresponds to the lenient parsing behavior for SimpleDateFormat
:
DateFormat (Java SE 11 & JDK 11) (oracle.com)
For now, this is not considered a bug in the system and there is no plan to change this behavior.
I'm still in the request to get the functioning of the third parameter in scope of this insight.
I think the easiest way to validate is to take these steps: