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