1.接手项目时测试发现页面时间格式不对,如图所示:
代码调整前:
<input type="text" name="recruitTime" th:field="*{recruitTime}" class="form-control" placeholder="yyyy-MM-dd HH:mm" required>
2.然后直接做日期格式化处理,如图所示:
代码部分调整后:
<input type="text" name="recruitTime" th:value="${#dates.format(calendar.recruitTime, 'yyyy-MM-dd HH:MM:SS')}" class="form-control" placeholder="yyyy-MM-dd HH:mm" required>
3.Thymeleaf界面格式化 ’年月日时分秒‘,代码如下:
th:value="${#dates.format(输入你的日期参数, 'yyyy-MM-dd HH:MM:SS')}"