Here you can find the source of getNearbyMonth(String month, int i)
public static String getNearbyMonth(String month, int i) throws ParseException
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static String getNearbyMonth(String month, int i) throws ParseException { SimpleDateFormat formatter = new SimpleDateFormat("yyyyMM"); Date mydate = formatter.parse(month); Calendar calendar = Calendar.getInstance(); calendar.setTime(mydate);//from w w w.j a v a2 s . com calendar.add(Calendar.MONTH, i); return formatter.format(calendar.getTime()); } }