How to work with dates in Thymeleaf (#960)

* How to work with dates in Thymeleaf

* Fixes in PR for Thymeleaf
This commit is contained in:
maibin
2017-01-08 16:01:41 +01:00
committed by KevinGilmore
parent 82fc8cf8fc
commit e36d928219
6 changed files with 94 additions and 18 deletions

View File

@@ -0,0 +1,25 @@
package com.baeldung.thymeleaf.controller;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
public class DatesController {
@RequestMapping(value = "/dates", method = RequestMethod.GET)
public String getInfo(Model model) {
model.addAttribute("standardDate", new Date());
model.addAttribute("localDateTime", LocalDateTime.now());
model.addAttribute("localDate", LocalDate.now());
model.addAttribute("timestamp", Instant.now());
return "dates.html";
}
}