Java_获取当前月最后一天
List<String> ms = DateUtils.getMonths(7,"yyyyMM"); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); for (String s : ms) { Calendar ca = Calendar.getInstance(); try { ca.setTime(sdf.parse(s + "01")); } catch (ParseException e) { e.printStackTrace(); } ca.set(Calendar.DAY_OF_MONTH, ca.getActualMaximum(Calendar.DAY_OF_MONTH)); String last = sdf.format(ca.getTime()); System.out.println("===============last:"+last); } Calendar ca = Calendar.getInstance(); ca.setTime(new Date()); ca.set(Calendar.DAY_OF_MONTH, ca.getActualMaximum(Calendar.DAY_OF_MONTH)); String last = sdf.format(ca.getTime()); System.out.println("===============当前月最后一个月:"+last);