easyui-datetimebox 日期转换

日期组件代码:

<td>开始时间</td>
<td>
    <input  name="startTime" class="easyui-datetimebox" />
</td>

startTime在表单中是字符串格式,当在后台需要时间为Date类型,此时可以通过以下方式进行转换。此段代码可以放在controller里面。

@InitBinder
    public void initBinder(WebDataBinder binder) {
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        dateFormat.setLenient(true);
        binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
    }

猜你喜欢

转载自blog.csdn.net/HAIMING157/article/details/79064683
今日推荐