Timestamp date = DateUtil.parseYYYYMM("2020-06"); LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); //本月的最后一天 LocalDate lastDay =localDate.with(TemporalAdjusters.lastDayOfMonth()); System.out.println("-------------------"+localDate.getYear()+"-"+localDate.getMonth().getValue()+"-"+lastDay.getDayOfMonth());
输出结果:
-------------------2020-6-30