java格式化日期为yyyy-MM-dd
1、使用hutool来简化我们的开发,u引入hutool的jar包

2、DateUtil.date();获取现在的时间对象

3、然后我们写一个时间格式为"yyyy-MM-dd"的字符串

4、DateUtil.format(date,format);将时间格式化为字符串

5、最后我们来看一下结果

1、使用hutool来简化我们的开发,u引入hutool的jar包
2、DateUtil.date();获取现在的时间对象
3、然后我们写一个时间格式为"yyyy-MM-dd"的字符串
4、DateUtil.format(date,format);将时间格式化为字符串
5、最后我们来看一下结果