A discussion forum for the JCommon class library.
2 posts • Page 1 of 1
I am getting an "invalid month" exception when I try to add 2 months to a date in October. Upon investigation it looks like there is a problem with the calculation of the months in SerialDate.addMonths:
int mm = (12 * base.getYYYY() + base.getMonth() + months) % 12;
returns 0 for December when it should return 12
I would suggest the following change. instead of (x%12) the formula should read ((x-1) % 12) + 1
This way december will return 12 and not zero.