Java Month Add addMonth(Date date, int month)

Here you can find the source of addMonth(Date date, int month)

Description

Addiert einen Monat.

License

Apache License

Parameter

Parameter Description
date the date
month the month

Return

the date

Declaration

public static Date addMonth(Date date, int month) 

Method Source Code

//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License");

import java.util.Calendar;
import java.util.Date;

public class Main {
    /**/*from   ww  w.j  av a  2  s . c o  m*/
     * Addiert einen Monat.
     *
     * @param date the date
     * @param month the month
     * @return the date
     */
    public static Date addMonth(Date date, int month) {
        final Calendar cal = getCalendarInstance();
        cal.setTime(date);
        cal.add(Calendar.MONTH, month);
        final Date result = cal.getTime();
        return result;
    }

    /**
     * Locale?
     *
     * @return Eine neue Instanz.
     */
    private static Calendar getCalendarInstance() {
        final Calendar cal = Calendar.getInstance();
        return cal;
    }
}

Related

  1. addMonth(Date date, int month)
  2. addMonth(Date date, int months)
  3. addMonths(Date date, int iMonthCount)
  4. addMonths(Date date, int months)
  5. addMonths(int updateInterval, String dateFormat)