add Month to Date - Android java.util

Android examples for java.util:Month

Description

add Month to Date

Demo Code


//package com.java2s;

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

public class Main {
    public static Date addMonth(Date date, int months) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);/*from  w  ww.  j a va2s  .co  m*/
        calendar.add(Calendar.MONTH, months);
        return calendar.getTime();
    }
}

Related Tutorials