Java Month Add addMonths(Date date, int iMonthCount)

Here you can find the source of addMonths(Date date, int iMonthCount)

Description

add Months

License

Open Source License

Parameter

Parameter Description
date a parameter
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.

Declaration

public static Date addMonths(Date date, int iMonthCount) 

Method Source Code


//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();
    }
}

Related

  1. addMonth(Date date, int month)
  2. addMonth(Date date, int month)
  3. addMonth(Date date, int months)
  4. addMonths(Date date, int months)
  5. addMonths(int updateInterval, String dateFormat)
  6. addMonths(java.util.Date today, int monthsToAdd)
  7. addMonths(String s, int month)