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()); // 抽出基準日の前月末日時点
转载于:https://www.cnblogs.com/TJessica/p/10303418.html