Guest User

Untitled

a guest
Feb 24th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. package com.my.web;
  2. import java.text.DateFormat;
  3. import java.util.Date;
  4. import java.util.Locale;
  5. import org.slf4j.Logger;
  6. import org.slf4j.LoggerFactory;
  7. import org.springframework.stereotype.Controller;
  8. import org.springframework.ui.Model;
  9. import org.springframework.web.bind.annotation.RequestMapping;
  10. import org.springframework.web.bind.annotation.RequestMethod;
  11. /**
  12. * Handles requests for the application home page.
  13. */
  14. @Controller
  15. public class HomeController {
  16.  
  17. private static final Logger logger = LoggerFactory.getLogger(HomeController.class);
  18.  
  19. /**
  20. * Simply selects the home view to render by returning its name.
  21. */
  22. @RequestMapping(value = "/", method = RequestMethod.GET)
  23. public String home(Locale locale, Model model) {
  24. logger.info("Welcome home! The client locale is {}.", locale);
  25.  
  26. Date date = new Date();
  27. DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
  28.  
  29. String formattedDate = dateFormat.format(date);
  30.  
  31. model.addAttribute("serverTime", formattedDate );
  32.  
  33. return "home";
  34. }
  35.  
  36. }
Add Comment
Please, Sign In to add comment