//月份跳转
//初始日期
String yearMonth = "201702";
String yearMonthStr = "";//往前(负数)或往后(正数)
int add = -2;
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM");Date source = sdf.parse(yearMonth);
Calendar cal = Calendar.getInstance();
cal.setTime(source);
cal.add(Calendar.MONTH, add);
yearMonthStr = sdf.format(cal.getTime());
System.out.println(yearMonthStr);
-------------------------------------------------------------------------------------
//天跳转
String yearMonth = "20170208";
String yearMonthStr = "";
int add = 3;
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
Date source = sdf.parse(yearMonth);
Calendar cal = Calendar.getInstance();
cal.setTime(source);
cal.add(Calendar.DATE, add);
yearMonthStr = sdf.format(cal.getTime());
System.out.println(yearMonthStr);