I need to get difference between two dates using Java. I need my result to be in months.
Example:
Startdate = 2013-04-03 enddate = 2013-05-03 Result should be 1
if the interval is
Startdate = 2013-04-03 enddate = 2014-04-03 Result should be 12
Using the following code I can get the results in days. How can I get in months?
Date startDate = new Date(2013,2,2);
Date endDate = new Date(2013,3,2);
int difInDays = (int) ((endDate.getTime() - startDate.getTime())/(1000*60*60*24));