1:代码
public static void main(String[] args) { System.out.println("今天:"+DateUtil.today()); //offset 偏移天数,正数向未来偏移,负数向历史偏移 System.out.println("10天前:"+DateUtil.format(DateUtil.offsetDay(DateUtil.date(), -10), "yyyy-MM-dd")); System.out.println("10天后:"+DateUtil.format(DateUtil.offsetDay(DateUtil.date(), 10), "yyyy-MM-dd")); System.out.println("当月第一天:"+DateUtil.format(DateUtil.beginOfMonth(DateUtil.date()), "yyyy-MM-dd")); System.out.println("当月最后一天:"+DateUtil.format(DateUtil.endOfMonth(DateUtil.date()), "yyyy-MM-dd"));}
2:输出效果
来源地址:https://blog.csdn.net/ww702109k/article/details/130647662