Here you can find the source of AddMonths(int yearMonth, int interval)
public static int AddMonths(int yearMonth, int interval) throws Exception
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static int AddMonths(int yearMonth, int interval) throws Exception { int result = 0; java.util.Date ym;//from ww w . j av a2 s . co m SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM"); ym = sdf.parse(String.valueOf(yearMonth)); Calendar cal = Calendar.getInstance(); cal.setTime(ym); cal.add(Calendar.MONTH, interval); result = Integer.parseInt(sdf.format(cal.getTime())); return result; } }