jdk1.8动态精准获取每个月份最后一天

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

猜你喜欢

转载自blog.csdn.net/qq_33767353/article/details/108336021
今日推荐