java 8 LocalDate 获取某月第一天与最后天

LocalDate date = LocalDate.parse("2019-08-01", DateTimeFormatter.ofPattern("yyyy-MM-dd"));
LocalDate first = date.with(TemporalAdjusters.firstDayOfMonth());
LocalDate last = date.with(TemporalAdjusters.lastDayOfMonth());
long days = first.until(last, ChronoUnit.DAYS);
System.out.println(days);
System.out.println(first.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
System.out.println(last.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
    原文作者:xie_k
    原文地址: https://blog.csdn.net/xiekongXK/article/details/102383930
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞