Hello Team , thanks for your efforts , though to share with you that i have found serious bug in "minusMonths" method of JODA Api, it wrongly calculates the days. please feel free to contact should you need any more details. .
Thanks a lot for making life easier for java community.
Kind Regards
raky
Calendar calObj = new GregorianCalendar();
calObj.setTimeZone(TimeZone.getTimeZone("Europe/london"));
Date todayDate = calObj.getTime();
DateTime todayDateObj = new DateTime(todayDate.getTime());
DateTime backDaysObj=todayDateObj.minusDays(9);
DateTime backMonthObj=backDaysObj.minusMonths(10);
DateTime backYearObj=backMonthObj.minusYears(10);
assertEquals("Age is 9 Days 10 Months 10 Years", "-10Years-10Months-9Days",
When the days/months/tears are subtracted and compared again with "current date" Joda api does not pass Junit test for all months ie. (I have used JODA Api for age calculation when dob is provided)
Junit test :
backDaysObj.minusMonths(1);Actual -10Years-1Months-8Days, expected -10Years-1Months-9Days
backDaysObj.minusMonths(2); PASS
backDaysObj.minusMonths(3);Fail Act-10Years-3Months-9Days Expctd-10Years-3Months-8Days
backDaysObj.minusMonths(4);PASS
backDaysObj.minusMonths(5);Fail -10Years-5Months-9Days -10Years-5Months-7Days
backDaysObj.minusMonths(6);PASS
backDaysObj.minusMonths(7);PASS
backDaysObj.minusMonths(8);FAIL -10Years-8Months-9Days -10Years-8Months-8Days
backDaysObj.minusMonths(9);PASS
backDaysObj.minusMonths(10);Fail -10Years-10Months-9Days -10Years-10Months-8Days
backDaysObj.minusMonths(11); PASS
Issues are no longer managed at sourceforge, they are only managed at GitHub https://github.com/JodaOrg/joda-time/issues
I'd also note that there is insufficient data to evaluate your issue. I'd need a specific base input date to confirm whether the output is correct or not. However, it is highly unlikely to be "wrong", it is only likely to be "different" from the answer you expected. Round tripping minus with plus is not a goal.