用thymeleaf格式化LocalDateTime
用thymeleaf将LocalDateTime类型的日期格式化为yyyy-MM-dd hh:mm:ss
LocalDateTime类型的日期格式为’yyyy-MM-ddThh:mm:ss’,日期和时间中间用T连接
如何去掉日期和时间中间的T?
解决方法如下:
1、在maven中添加依赖
<dependency><groupId>org.thymeleaf.extras</groupId><artifactId>thymeleaf-extras-java8time</artifactId><version>3.0.1.RELEASE</version></dependency>
2、前端页面
<span th:text="${#temporals.format(localDateTime, 'dd-MM-yyyy HH:mm:ss')}"></span>