/** * 获取当前月的上一个月 * @return */ public static String getLastMonth() { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM"); Date date = new Date(); Calendar calendar = Calendar.getInstance(); calendar.setTime(date); // 设置为当前时间 calendar.add(Calendar.MONTH,-1); date = calendar.getTime(); String accDate = format.format(date); return accDate; }