code: private static BigInteger computeDays(BigInteger months, int refYear, int refMonth) {
      switch (months.signum()) {
      case 0:
        return BigInteger.valueOf(0);
      case -1:
        return computeDays(months.negate(), refYear, refMonth).negate();
      }
      // Complete cycle of Gregorian calendar is 400 years
      BigInteger[] tem = months.divideAndRemainder(BigInteger.valueOf(400*12));
      --refMonth; // use 0 base to match Java
      int total = 0;
      for (int rem = tem[1].intValue(); rem > 0; rem--) {
        total += daysInMonth(refYear, refMonth);
        if (++refMonth == 12) {
          refMonth = 0;
          refYear++;
        }
      }
      // In the Gregorian calendar, there are 97 (= 100 + 4 - 1) leap years every 400 years.
      return tem[0].multiply(BigInteger.valueOf(365*400 + 97)).add(BigInteger.valueOf(total));
    }
docs: Returns the number of days spanned by a period of months starting with a particular
  reference year and month.