我需要打印当月的过去6个月的名字.
例如,在2016年4月运行时,我需要打印:nov(2015),dec(2015),jan(2016),feb(2016),march(2016),4月(2016)
Format formatter = new SimpleDateFormat("MMMM YYYY");
Calendar c = Calendar.getInstance();
String[] thisAndLastFiveMonths = new String[6];
for (int i = 0; i < thisAndLastFiveMonths.length; i++) {
thisAndLastFiveMonths[i] = formatter.format(c.getTime());
c.add(Calendar.MONTH, -1);
System.out.println(c);
Run Code Online (Sandbox Code Playgroud)