后端相关代码:
/** 时间 */
@JsonFormat(pattern = “yyyy-MM” ,timezone=“GMT+8” ) //导入相关的包
@Excel(name = “时间”, width = 30, dateFormat = “yyyy-MM-dd”)
private Date time;
html页面代码:
<ul>
<li th:each="developmentHistorie:${developmentHistories}">
<p th:text="${developmentHistorie.time}"></p>
<p th:text="${developmentHistorie.developmentHistoryTxt}"></p>
</li>
</ul>
刚开始 直接从遍历出来的对象中取值结果前端页面显示为:
日期 月,日为英文。
只改html页面为如下 #dates.format :
<ul>
<li th:each="developmentHistorie:${developmentHistories}">
<p th:text="${#dates.format(developmentHistorie.time,'yyyy-MM')}"></p>
<p th:text="${developmentHistorie.developmentHistoryTxt}"></p>
</li>
</ul>
就把英文该成数字了(我这里没有加时分秒 需要的在yyyy-MM 后加就行 ‘yyyy-MM-dd HH:mm:ss’
具体可以调)
这里实际上很简单,就只是themleaf中标签对日期格式转换的使用。对这些标签的具体使用做不到倒背如流,只能踩坑弥补了。(踩坑ing。。。。)