hibernate jpa 注解 @Temporal(TemporalType.DATE) 格式化时间日期,页面直接得到格式化类型的值
2015-12-04 09:30
507 查看
1.日期:
@Temporal(TemporalType.DATE)
@Column(name = "applyDate", nullable = false, length = 10)
public Date getApplyDate() {
return applyDate;
}
在页面端取值:2011-04-12
2.时间:
@Temporal(TemporalType.TIME)
在页面端取值:22:50:30
3.日期和时间(默认):
@Temporal(TemporalType.TIMESTAMP)
在页面端取值:2011-04-12 22:51:34.0
JSTL 格式化date
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<fmt:formatDate pattern="【yyyy-MM-dd】" value="${data.createTime }" type="both"/>
Dates
Tag Output
Attribute: value; required. Tag has no body.
<fmt:formatDate value="${date}" type="both"/>
2004-4-1 13:30:00
<fmt:formatDate value="${isoDate}" type="both"/>
2004-5-31 23:59:59
Attribute: type; optional. Indicates what to print: date, time, or both.
<fmt:formatDate value="${date}" type="date"/>
2004-4-1
<fmt:formatDate value="${isoDate}" type="time"/>
23:59:59
Attribute: dateStyle; optional. Varies the date format.
<fmt:formatDate value="${isoDate}" type="date" dateStyle="default"/>
2004-5-31
<fmt:formatDate value="${isoDate}" type="date" dateStyle="short"/>
04-5-31
<fmt:formatDate value="${isoDate}" type="date" dateStyle="medium"/>
2004-5-31
<fmt:formatDate value="${isoDate}" type="date" dateStyle="long"/>
2004年5月31日
<fmt:formatDate value="${isoDate}" type="date" dateStyle="full"/>
2004年5月31日 星期一
Attribute: timeStyle; optional. Varies the time format.
<fmt:formatDate value="${isoDate}" type="time" timeStyle="default"/>
23:59:59
<fmt:formatDate value="${isoDate}" type="time" timeStyle="short"/>
下午11:59
<fmt:formatDate value="${isoDate}" type="time" timeStyle="medium"/>
23:59:59
<fmt:formatDate value="${isoDate}" type="time" timeStyle="long"/>
下午11时59分59秒
<fmt:formatDate value="${isoDate}" type="time" timeStyle="full"/>
下午11时59分59秒 CDT
Attribute: pattern; optional. Inidcates date/time custom patterns.
<fmt:formatDate value="${date}" type="both" pattern="EEEE, MMMM d, yyyy HH:mm:ss Z"/>
星期四, 四月 1, 2004 13:30:00 -0600
<fmt:formatDate value="${isoDate}" type="both" pattern="d MMM yy, h:m:s a zzzz/>
@Temporal(TemporalType.DATE)
@Column(name = "applyDate", nullable = false, length = 10)
public Date getApplyDate() {
return applyDate;
}
在页面端取值:2011-04-12
2.时间:
@Temporal(TemporalType.TIME)
在页面端取值:22:50:30
3.日期和时间(默认):
@Temporal(TemporalType.TIMESTAMP)
在页面端取值:2011-04-12 22:51:34.0
JSTL 格式化date
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<fmt:formatDate pattern="【yyyy-MM-dd】" value="${data.createTime }" type="both"/>
Dates
Tag Output
Attribute: value; required. Tag has no body.
<fmt:formatDate value="${date}" type="both"/>
2004-4-1 13:30:00
<fmt:formatDate value="${isoDate}" type="both"/>
2004-5-31 23:59:59
Attribute: type; optional. Indicates what to print: date, time, or both.
<fmt:formatDate value="${date}" type="date"/>
2004-4-1
<fmt:formatDate value="${isoDate}" type="time"/>
23:59:59
Attribute: dateStyle; optional. Varies the date format.
<fmt:formatDate value="${isoDate}" type="date" dateStyle="default"/>
2004-5-31
<fmt:formatDate value="${isoDate}" type="date" dateStyle="short"/>
04-5-31
<fmt:formatDate value="${isoDate}" type="date" dateStyle="medium"/>
2004-5-31
<fmt:formatDate value="${isoDate}" type="date" dateStyle="long"/>
2004年5月31日
<fmt:formatDate value="${isoDate}" type="date" dateStyle="full"/>
2004年5月31日 星期一
Attribute: timeStyle; optional. Varies the time format.
<fmt:formatDate value="${isoDate}" type="time" timeStyle="default"/>
23:59:59
<fmt:formatDate value="${isoDate}" type="time" timeStyle="short"/>
下午11:59
<fmt:formatDate value="${isoDate}" type="time" timeStyle="medium"/>
23:59:59
<fmt:formatDate value="${isoDate}" type="time" timeStyle="long"/>
下午11时59分59秒
<fmt:formatDate value="${isoDate}" type="time" timeStyle="full"/>
下午11时59分59秒 CDT
Attribute: pattern; optional. Inidcates date/time custom patterns.
<fmt:formatDate value="${date}" type="both" pattern="EEEE, MMMM d, yyyy HH:mm:ss Z"/>
星期四, 四月 1, 2004 13:30:00 -0600
<fmt:formatDate value="${isoDate}" type="both" pattern="d MMM yy, h:m:s a zzzz/>
相关文章推荐
- 限制UITextField 输入字数
- PL/SQL 按日期查询问题
- 第十周项目3-利用二叉树遍历思想解决问题(5)
- 奥运会出票系统
- 脉络清晰的BP神经网络讲解,赞
- 脉络清晰的BP神经网络讲解,赞
- 苹果官方github地址
- Android中使用include标签和merge标签重复使用布局
- ARM寻址方式及相关指令汇总
- c++/c实现线程池
- 用FileExplorer查看android手机中的数据库
- mysql 1067错误
- HTTPS和HTTP的区别
- 隐私政策
- jquery解决插件冲突
- Longest Common Prefix
- hdu 3460 Ancient Printer
- VS C++ 控件使用
- vSphere Management Assistant(VMA) 命令行修改IP
- 串口驱动移植心得