我正在使用Springboot,Java和Thymeleaf。

public class DirectBind {

    @Column(columnDefinition = "date")
    @DateTimeFormat(pattern = "MM/dd/yyyy")
    private LocalDate policyTermDateStart;

    @Column(columnDefinition = "date")
    @DateTimeFormat(pattern = "MM/dd/yyyy")
 ...
}




我的约会日期是yyyy-mm-dd。您知道我如何更改此代码/在何处实现代码以使其更改。它在我的控制器中吗?这是我发送捕获日期用户输入的表单时的代码

@RequestMapping(value = "/send")
public String send(Model model, @ModelAttribute(value = "directBind") DirectBind directBind) {
    List<String> businessAgencyList = directBind.getBusinessAgencyList();
    List<String> billTypeOptions = directBind.getBillTypeOptions();
    Mail mail = new Mail();
    mail.setFrom("[email protected]");
    mail.setTo(new String[]{"[email protected]"});
    mail.setSubject("Oli Affiliate - AMS360 & PMA Data Checklist");
    Map<String, Object> mailModel = new HashMap<>();
    mail.setModel(mailModel);
    try {
        emailService.sendSimpleMessage(mail, directBind);
    } catch (Exception e) {
        e.printStackTrace();
        return ("redirect:/?sentMessageFail");
    }
    return ("redirect:/?sentMessage");
}

@RequestMapping(value = "/email")
public String email() {
    return "emailMessage";
}

最佳答案

使用#temporals可以正常工作!



<tr class="emailRow">
        <td colspan="1" class="dateRangeEnd" th:text="${#temporals.format(directBind.policyTermDateEnd, 'MM/dd/yyyy')}">
         </td>
</tr>

07-26 06:30