Created
March 15, 2012 08:07
-
-
Save beans9/2042863 to your computer and use it in GitHub Desktop.
HomeController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package www.beans9.com; | |
import java.text.DateFormat; | |
import java.util.Date; | |
import java.util.Locale; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import org.springframework.stereotype.Controller; | |
import org.springframework.ui.Model; | |
import org.springframework.web.bind.annotation.RequestMapping; | |
import org.springframework.web.bind.annotation.RequestMethod; | |
@Controller | |
public class HomeController { | |
private static final Logger logger = LoggerFactory.getLogger(HomeController.class); | |
@RequestMapping(value = "/", method = RequestMethod.GET) | |
public String home(Locale locale, Model model) { | |
logger.info("Welcome home! the client locale is "+ locale.toString()); | |
Date date = new Date(); | |
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale); | |
String formattedDate = dateFormat.format(date); | |
model.addAttribute("serverTime", formattedDate ); | |
return "home"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment