使用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
}
浙公网安备 33010602011771号