class PackedLocalDate {

  public static int plusMonths(int months, int packedDate) {
    if (months == 0) {
      return packedDate;
    }

    byte d = getDayOfMonth(packedDate);
    byte m = getMonthValue(packedDate);
    short y = getYear(packedDate);

    long monthCount = y * 12L + (m - 1);
    long calcMonths = monthCount + months;
    int newYear = YEAR.checkValidIntValue(Math.floorDiv((int) calcMonths, 12));
    int newMonth = Math.floorMod((int) calcMonths, 12) + 1;
    return resolvePreviousValid(newYear, newMonth, d);
  }

}