首页 > 其他 > 详细

自定义格式日期

时间:2019-07-18 14:46:39      阅读:78      评论:0      收藏:0      [点我收藏+]

使用日期页面需导入包:

<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

自定义日期格式:

<fmt:formatDate value="${日期}" pattern="yyyy-MM--dd HH:mm:ss"/>

 

前端日期存入数据库成date日期需在使用日期的类中加载此方法:

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

自定义格式日期

原文:https://www.cnblogs.com/zhangrongfei/p/11206696.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!