Java 前一个月的最后一天日期计算

  String calDate = exportDate1.replace("/", "").replace("-", "");
  SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
  Calendar calendar = Calendar.getInstance();
  calendar.set(Calendar.YEAR, Integer.parseInt(calDate.substring(0, 4)));
  calendar.set(Calendar.MONTH, Integer.parseInt(calDate.substring(4, 5)) -1);
  calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
     exportDate2 = sdf.format(calendar.getTime());  // 抽出基準日の前月末日時点

posted @ 2019-01-22 13:52  弄丢的小可爱🌸  阅读(482)  评论(0编辑  收藏  举报