Commit 24c20f31 by Patryk Czarnik

show_time5

parent b02f784f
......@@ -6,6 +6,7 @@ import java.time.format.DateTimeFormatter;
import java.util.Locale;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
......@@ -49,9 +50,10 @@ public class DateTimeController {
}
@RequestMapping("/time5")
public String time5() {
public String time5(Model model) {
LocalDateTime dt = LocalDateTime.now();
model.addAttribute("czas", dt);
model.addAttribute("sformatowany_czas", dt.format(FORMAT_DATY));
return "show_time5.html";
}
......
......@@ -8,6 +8,17 @@
<h1>Która godzina 5</h1>
<p>Zaraz powiem, która jest godzina...</p>
<p>Otóż teraz jest: [[${czas}]]</p>
<h3>Wybrane pola daty i czasu</h3>
<ul>
<li>rok: [[${czas.year}]]</li>
<li>dzień roku: [[${czas.dayOfYear}]]</li>
<li>sekunda: [[${czas.second}]]</li>
<li>cała data: [[${czas.toLocalDate()}]]</li>
</ul>
<h3>Sformatowany czas:</h3>
<p>[[${sformatowany_czas}]]</p>
</body>
</html>
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