java 时间格式转换

2014-11-23 19:32:19 · 作者: · 浏览: 14

把2014-5-5 22:02:11:15 这样格式的时间转换成2014年5月5日

SimpleDateFormat in = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

SimpleDateFormat out = new SimpleDateFormat("yyyy年MM月dd日");
String s;
try {
s = out.format(in.parse("2014-5-5 22:02:11"));
Log.i("", "msg s = "+s);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();

}

打印结果:2014年5月5日