当前位置: 代码迷 >> J2EE >> 数据库日期有关问题
  详细解决方案

数据库日期有关问题

热度:50   发布时间:2016-04-21 22:21:43.0
数据库日期问题
在数据库中存放 日期 的格式是字符串,为20131203
但是在页面中需要显示yyyy-MM-dd HH:mm:ss的格式
数据库 日期 格式

------解决方案--------------------
	public static void main(String[] args) throws Exception {
String date = "20131203";
DateFormat df = new SimpleDateFormat("yyyyMMdd");
Date d = df.parse(date);
df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String newDate = df.format(d);
System.out.println(newDate);
}
  相关解决方案