kma*_*oor 3 spring spring-mvc jodatime
我有一个java.util.Date的initbinder:
@InitBinder
public void initBinder(WebDataBinder binder) {
SimpleDateFormat dateFormat = new SimpleDateFormat(
Constants.DATE_PICTURE);
dateFormat.setLenient(false);
binder.registerCustomEditor(Date.class, new CustomDateEditor(
dateFormat, true));
Run Code Online (Sandbox Code Playgroud)
什么可以用来绑定一个joda时间LocalDateTime?我正在使用Spring 3.1
当您使用命令对象时,可以使用完全不同的,更优雅的方法:使用@DateTimeFormat注释.
public class CommandObject {
@DateTimeFormat(pattern="yyyy/MM/dd hh:mm:ss a")
public Date myDate();
}
@Controller
public class ControllerClass{
@RequestMapping("/myUrl")
public ModelAndView(CommandObject c) {...}
}
Run Code Online (Sandbox Code Playgroud)
(@查看此博客以获取一些示例格式化程序)
| 归档时间: |
|
| 查看次数: |
1397 次 |
| 最近记录: |