SpringBoot结合velocity模板,可以通过toolbox来格式化时间 在resources目录下新建toolbox.xml文件,添加如下代码
<?xml version="1.0" encoding="UTF-8"?>
<toolbox>
<tool>
<key>date
</key>
<scope>application
</scope>
<class>org.apache.velocity.tools.generic.DateTool
</class>
</tool>
</toolbox>
在application.properties文件中添加配置:
spring
.velocity.toolbox-config-location=toolbox
.xml
使用:
$date.
format(
'yyyy-MM-dd HH:mm:ss',
$!{user.createdDate})
转载请注明原文地址: https://ju.6miu.com/read-661861.html