Commit 32bc9dae by Patryk Czarnik

lista kolejnych dni

parent b5f1cbef
package com.example.demo;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import org.springframework.stereotype.Controller;
......@@ -70,6 +73,14 @@ public class DateTimeController {
public String time6(Model model) {
LocalDateTime dt = LocalDateTime.now();
model.addAttribute("dt", dt);
List<LocalDate> dates = new ArrayList<>();
LocalDate date = dt.toLocalDate();
for(int i = 0; i <= 5; i++) {
dates.add(date.plusWeeks(i));
}
model.addAttribute("futureWeeks", dates);
return "show_time6.html";
}
......
......@@ -44,5 +44,11 @@
<li>czas: <strong th:text="${dt.toLocalTime()}">10:44:22</strong></li>
</ul>
<h3>Odczyt elementów listy</h3>
<p>Ten sam dzień w kolejnych tygodniach:</p>
<ol start="0">
<li th:each="date : ${futureWeeks}" th:text="${date}">2022-08-01</li>
</ol>
</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