Here you can find the source of addMonths(Date date, int iMonthCount)
Parameter | Description |
---|---|
date | a parameter |
iMonthCount | number of months to add (may be 0 or negative). |
public static Date addMonths(Date date, int iMonthCount)
//package com.java2s; //it under the terms of the GNU Affero General Public License as published by import java.util.Calendar; import java.util.Date; public class Main { /**/*from w ww.j a va 2s.c o m*/ * @param date * @param iMonthCount number of months to add (may be 0 or negative). * @return a new date resulting from adding the given number of months to the given date. */ public static Date addMonths(Date date, int iMonthCount) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.add(Calendar.MONTH, iMonthCount); return calendar.getTime(); } }