Commit fd7cd627 by Patryk Czarnik

Bieżący czas - wersja z szablonem

parent a3e75687
...@@ -6,6 +6,7 @@ import java.time.format.DateTimeFormatter; ...@@ -6,6 +6,7 @@ import java.time.format.DateTimeFormatter;
import java.util.Locale; import java.util.Locale;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
...@@ -59,5 +60,11 @@ public class PierwszyKontroler { ...@@ -59,5 +60,11 @@ public class PierwszyKontroler {
dt.toLocalTime(), dt.toLocalDate(), dt.format(FORMAT_DATY)); dt.toLocalTime(), dt.toLocalDate(), dt.format(FORMAT_DATY));
} }
@GetMapping("/time5")
public String time5(Model model) {
LocalDateTime now = LocalDateTime.now();
model.addAttribute("dt", now);
return "wyswietl_czas5.html";
}
} }
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Bieżący czas</title>
</head>
<body>
<h1>Bieżący czas</h1>
<p>Bieżący czas: [[${dt}]]</p>
<p>Dzień miesiąca: [[${dt.dayOfMonth}]]</p>
<p>Dzień roku: [[${dt.dayOfYear}]]</p>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment