|
|
@ -11,15 +11,26 @@ import java.time.format.DateTimeFormatter; |
|
|
|
public class Manager { |
|
|
|
@GetMapping({"/", "", "/index"}) |
|
|
|
public String welcome(Model model){ |
|
|
|
loadTheme(model); |
|
|
|
model.addAttribute("mesage", "Hello"); |
|
|
|
return "index"; |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/hour") |
|
|
|
public String hour(Model model){ |
|
|
|
loadTheme(model); |
|
|
|
return "time"; |
|
|
|
} |
|
|
|
|
|
|
|
private void loadTheme(Model model) { |
|
|
|
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm:ss"); |
|
|
|
model.addAttribute("dateTime", dtf.format(LocalDateTime.now())); |
|
|
|
// model.addAttribute("bg", "dark"); |
|
|
|
return "time"; |
|
|
|
DateTimeFormatter hour = DateTimeFormatter.ofPattern("HH"); |
|
|
|
int h = Integer.parseInt(hour.format(LocalDateTime.now())); |
|
|
|
String bg = "light"; |
|
|
|
if (h >= 20 || h <= 7){ |
|
|
|
bg = "dark"; |
|
|
|
} |
|
|
|
model.addAttribute("background", bg); |
|
|
|
} |
|
|
|
} |