code: public static long subMonths(final Date date1, final Date date2) {
  
      Calendar calendar1 = buildCalendar(date1);
      int monthOfDate1 = calendar1.get(Calendar.MONTH);
      int yearOfDate1 = calendar1.get(Calendar.YEAR);
      Calendar calendar2 = buildCalendar(date2);
      int monthOfDate2 = calendar2.get(Calendar.MONTH);
      int yearOfDate2 = calendar2.get(Calendar.YEAR);
      int subMonth = Math.abs(monthOfDate1 - monthOfDate2);
      int subYear = Math.abs(yearOfDate1 - yearOfDate2);
      return subYear * 12 + subMonth;
    }
docs: Get how many months between two date.
  
  @param date1 date to be tested.
  @param date2 date to be tested.
  @return how many months between two date.