判断两个日期其间是否超过指定月份间隔

判断两个日期之间是否超过指定月份间隔
    /**
     * @param d1 第一个日期
     * @param d2 第二个时间
     * @param definemonth 指定月份间隔
     * @return  如果两个日期之间的间隔时间超过 definemoth定义的时间间隔 那么返回true 否则返回false
     */
    public static boolean dateDudge(Date d1, Date d2,int  definemonth)
    {
   
    Calendar c = Calendar.getInstance();
    c.setTimeZone(TimeZone.getDefault());
   
    c.setTime(d1);
    int year1 = c.get(Calendar.YEAR);
    int month1 = c.get(Calendar.MONTH) + 1;
    int day1 = c.get(Calendar.DAY_OF_MONTH);
   
    c.setTime(d2);
    int year2 = c.get(Calendar.YEAR);
    int month2 = c.get(Calendar.MONTH) + 1;
    int day2 = c.get(Calendar.DAY_OF_MONTH);
   
int month = Math.abs((year2 - year1) * 12 + (month2 - month1));

if (month > definemonth)
return true;
else if (month == definemonth) {
if (month2 > month1) {
if (day2 - day1 >= 0)
return true;
else
return false;
} else {
if (day1 - day2 >= 0)
return true;
else
return false;
}

} else {
return false;

}
   
    }