使用Hutool对时间的花式操作

1.根据当前时间往前推N天,且只保留日期,时间置为00:00:00

    /**
     * 当前时间往前推90天,且只保留日期,时分秒置为00:00:00
     */
    public static void test8() {
        Date today = new Date();
        Date lastDay = DateUtil.offsetDay(today, -90);
        Date lastDay2 = DateUtil.beginOfDay(lastDay);
        System.out.println(lastDay);       //2026-01-24 17:18:36
        System.out.println(lastDay2);      //2026-01-24 00:00:00
    }

 

posted on 2026-04-24 17:19  有点懒惰的大青年  阅读(26)  评论(0)    收藏  举报