utility object, java8time
This commit is contained in:
@@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -57,6 +58,13 @@ public class BasicController {
|
|||||||
return "basic/basic-objects";
|
return "basic/basic-objects";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/date")
|
||||||
|
public String date(Model model) {
|
||||||
|
model.addAttribute("localDateTime", LocalDateTime.now());
|
||||||
|
return "basic/date";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Component("helloBean")
|
@Component("helloBean")
|
||||||
static class HelloBean {
|
static class HelloBean {
|
||||||
public String hello(String data) {
|
public String hello(String data) {
|
||||||
|
|||||||
29
thymeleaf/src/main/resources/templates/basic/date.html
Normal file
29
thymeleaf/src/main/resources/templates/basic/date.html
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Title</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>LocalDateTime</h1>
|
||||||
|
<ul>
|
||||||
|
<li>default = <span th:text="${localDateTime}"></span></li>
|
||||||
|
<li>yyyy-MM-dd HH:mm:ss = <span th:text="${#temporals.format(localDateTime,'yyyy-MM-dd HH:mm:ss')}"></span></li>
|
||||||
|
</ul>
|
||||||
|
<h1>LocalDateTime - Utils</h1>
|
||||||
|
<ul>
|
||||||
|
<li>${#temporals.day(localDateTime)} = <span th:text="${#temporals.day(localDateTime)}"></span></li>
|
||||||
|
<li>${#temporals.month(localDateTime)} = <span th:text="${#temporals.month(localDateTime)}"></span></li>
|
||||||
|
<li>${#temporals.monthName(localDateTime)} = <span th:text="${#temporals.monthName(localDateTime)}"></span></li>
|
||||||
|
<li>${#temporals.monthNameShort(localDateTime)} = <span th:text="${#temporals.monthNameShort(localDateTime)}"></span></li>
|
||||||
|
<li>${#temporals.year(localDateTime)} = <span th:text="${#temporals.year(localDateTime)}"></span></li>
|
||||||
|
<li>${#temporals.dayOfWeek(localDateTime)} = <span th:text="${#temporals.dayOfWeek(localDateTime)}"></span></li>
|
||||||
|
<li>${#temporals.dayOfWeekName(localDateTime)} = <span th:text="${#temporals.dayOfWeekName(localDateTime)}"></span></li>
|
||||||
|
<li>${#temporals.dayOfWeekNameShort(localDateTime)} = <span th:text="${#temporals.dayOfWeekNameShort(localDateTime)}"></span></li>
|
||||||
|
<li>${#temporals.hour(localDateTime)} = <span th:text="${#temporals.hour(localDateTime)}"></span></li>
|
||||||
|
<li>${#temporals.minute(localDateTime)} = <span th:text="${#temporals.minute(localDateTime)}"></span></li>
|
||||||
|
<li>${#temporals.second(localDateTime)} = <span th:text="${#temporals.second(localDateTime)}"></span></li>
|
||||||
|
<li>${#temporals.nanosecond(localDateTime)} = <span th:text="${#temporals.nanosecond(localDateTime)}"></span></li>
|
||||||
|
</ul>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user