Thursday, March 22, 2012

Calculating the number of months between two dates

I've seen a few of these solutions on stackoverflow and I figured it would be worth remembering so, here is how you can calculate how many months are between two dates.

And a test that assumes that this method is in the DateUtils class and that the DateUtils class has an addToDate method (simply using the calendar's add method)

No comments:

Post a Comment