HelloController.java 820 B

123456789101112131415161718192021222324252627
  1. package pl.dmcs.mati.controller;
  2. import org.springframework.stereotype.Controller;
  3. import org.springframework.ui.Model;
  4. import org.springframework.web.bind.annotation.RequestMapping;
  5. import java.text.DateFormat;
  6. import java.util.Date;
  7. import java.util.Locale;
  8. @Controller
  9. public class HelloController {
  10. @RequestMapping(value = "/")
  11. public String helloWorld(Locale locale, Model model) {
  12. Date date = new Date();
  13. DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
  14. String formattedDate = dateFormat.format(date);
  15. model.addAttribute("serverTime", formattedDate );
  16. model.addAttribute("message","Polish characters encoding: ółźżćśńąęÓŁŹŻĆŚŃĄĘ");
  17. return "hello";
  18. }
  19. }