@GetMapping(value = "")
public String init(Model m) {
LocalDateTime ldt = LocalDateTime.now();
Timestamp ts = Timestamp.valueOf(ldt);
m.addAttribute("ts", ts); // ts = 2021-01-09 17:38:27.918333
return "index";
}
<p th:text="${#dates.format(new java.util.Date(ts), 'yyyy-MM-dd hh:mm')}"></p>
<!--output: 2021-01-09 17:38 -->
Recommended Posts