Java開発入門–@Temporal(TemporalType.DATE)の使い方
1.基本知識
DATE ->java.sql.Date
TIME ->java.sql.Time
TIMESTAMP->java.sql.Timestamp
2.年月日DATE
@Temporal(TemporalType.DATE)
@Column(name = “updateDate", nullable = false, length = 10)
public Date getUpdateDate() {
return updateDate;
}
結果:2016-06-05
3.時間TIME
@Temporal(TemporalType.TIME)
結果:12:50:30
4.TIMESTAMP
@Temporal(TemporalType.TIMESTAMP)
結果:2016-06-05 12:51:34:000
5.JSP画面に日時を表示
<td align="center"> <fmt:formatDate value="${list[0].createTime}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate></td>