我使用下面的代码来检索当前日期和时间,然后使用以下方法将其添加到表中。如何将当前日期时间的格式设置为不同的格式?
Change 2013-07-29 23:20:34.0 to 29th July 2013, 11:20 PM
的DateTime
public Date getCurrentDateTime() {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date();
System.out.println("current:" + dateFormat.format(date));
return date;
}
休眠
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
public Date getCurrentDateTime() {
return date;
}
因为你可以用dd-MMMM-YYYY它是如何以往任何时候都将所需的日期格式jsp页面日期不显示th – pundit
,所以你想从数据库中得到它时格式化它? –