public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {if (args.length != 2) {return ErrorEval.VALUE_INVALID;}try {double startDateAsNumber = NumericFunction.singleOperandEvaluate(args[0], ec.getRowIndex(), ec.getColumnIndex());int months = (int) NumericFunction.singleOperandEvaluate(args[1], ec.getRowIndex(), ec.getColumnIndex());if (startDateAsNumber >= 0.0 && startDateAsNumber < 1.0) {startDateAsNumber = 1.0;}Date startDate = DateUtil.getJavaDate(startDateAsNumber, false);Calendar cal = LocaleUtil.getLocaleCalendar();cal.setTime(startDate);cal.clear(Calendar.HOUR);cal.set(Calendar.HOUR_OF_DAY, 0);cal.clear(Calendar.MINUTE);cal.clear(Calendar.SECOND);cal.clear(Calendar.MILLISECOND);cal.add(Calendar.MONTH, months + 1);cal.set(Calendar.DAY_OF_MONTH, 1);cal.add(Calendar.DAY_OF_MONTH, -1);return new NumberEval(DateUtil.getExcelDate(cal.getTime()));} catch (EvaluationException e) {return e.getErrorEval();}}
public ValueEval Evaluate(ValueEval[] args, OperationEvaluationContext ec){if (args.Length != 2){return ErrorEval.VALUE_INVALID;}try{double startDateAsNumber = NumericFunction.SingleOperandEvaluate(args[0], ec.RowIndex, ec.ColumnIndex);int months = (int)NumericFunction.SingleOperandEvaluate(args[1], ec.RowIndex, ec.ColumnIndex);if (startDateAsNumber >= 0.0 && startDateAsNumber < 1.0){startDateAsNumber = 1.0;}DateTime startDate = DateUtil.GetJavaDate(startDateAsNumber, false);DateTime dtEnd = startDate.AddMonths(months);dtEnd = dtEnd.AddMonths(1);dtEnd = new DateTime(dtEnd.Year, dtEnd.Month, 1);dtEnd = dtEnd.AddDays(-1);return new NumberEval(DateUtil.GetExcelDate(dtEnd));}catch (EvaluationException e){return e.GetErrorEval();}}