// 每一个1号删除上个月的数据 public String calculateDay() { String dd = ""; DateFormat dateFormat = new SimpleDateFormat("yyyy-MM"); String nowdayTime = dateFormat.format(new Date()); try { dateFormat.parse(nowdayTime); } catch (ParseException e) { e.printStackTrace(); } String[] timStrings = nowdayTime.split("-"); String nowYear = timStrings[0]; String nowMath = timStrings[1]; if (nowMath.equals("01")) { int lastYear = Integer.parseInt(nowYear) - 1; dd = lastYear + ""; } else { int lastMath = Integer.parseInt(nowMath) - 1; String lastMath_ = String.format("%02d", lastMath); String s = nowYear + "-" + lastMath_; dd = s; } System.err.println(dd); return dd; }