/**
* 计算两个时间月数的差
* @param date1 减数
* @param date2 被减数
* @return 月数的差
*/
public static int calculateMonthIn(Date date1, Date date2) {
Calendar cal1 = new GregorianCalendar();
cal1.setTime(date1);
Calendar cal2 = new GregorianCalendar();
cal2.setTime(date2);
int c =
(cal1.get(Calendar.YEAR) - cal2.get(Calendar.YEAR)) * 12 + cal1.get(Calendar.MONTH)
- cal2.get(Calendar.MONTH);
return c;
}