Java8 求本月的第一天和最后一天

public class DateDemo {
    public static void main(String[] args) {
        LocalDate today = LocalDate.now();
        //本月的第一天
        LocalDate firstday = LocalDate.of(today.getYear(),today.getMonth(),1);
        //本月的最后一天
        LocalDate lastDay =today.with(TemporalAdjusters.lastDayOfMonth());
        System.out.println("本月的第一天"+firstday);
        System.out.println("本月的最后一天"+lastDay);
    }
}
    原文作者:红土豆_jie
    原文地址: https://blog.csdn.net/u010031939/article/details/53908678
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞