LoginSignup
2
2

More than 3 years have passed since last update.

ThymeleafでTimestamp型をフォーマットする

Posted at
  @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>
<!-- 出力: 2021-01-09 17:38 -->
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2