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:
@@ -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";
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user