Why in some cases, if you add a period to the date and delete the normal java 8 period, return a different date?
Due to the fact that calendar arithmetic work - months - is an uneven length, and this makes things complicated, to say the least.
You add "six years, one month, one day" until January 30, 2023. What do you expect from the result? There are potentially several different options ... logically, it sounds as if you mean "February 31, 2029", which does not exist ... so the API rolls it until March 1, 2029.
Now the deduction of six years, one month and one day from March 1, 2029 is also somewhat ambiguous, but it seems reasonable to do this on January 31, 2023 - if you subtract 6 years to get to March 1, 2023, then 1 month to get to February 1, 2023, and then 1 day you will reach January 31.
Basically: don't expect calendar arithmetic to behave like ordinary math. It just doesn't work.
source share