现在有个字符串是这样的
20120520152345
代表时间是 2012年5月20日15点23分45秒
怎么能转换成
2012-05-20 15:23:45呢?
Java
------解决方案--------------------
String source = "20120520152345";
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
String result = sdf1.format(sdf.parse(source));
System.out.println(result);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}