/**
* @param String emsTime:需要转换的日期
* @param SimpleDateFormat sdf_2:标准转换格式
* @param String emsTimeFormat_1:最2转换方式
* @throws
* @author imanong
* ModifyDate:2012-05-09
*/
public class ToTime {
public static void main(String[] args) {String emsTime = "20110624084955.0";
String emsTimeFormat_1 = emsTime.substring(0,4)+"-"+emsTime.substring(4,6)+"-"+emsTime.substring(6, 8)
+" "+emsTime.substring(8, 10)+":"+emsTime.substring(10, 12)+":"+emsTime.substring(12, 14);
SimpleDateFormat sdf_1 = new SimpleDateFormat("yyyyMMddHHmmss.0");
SimpleDateFormat sdf_2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String emsTimeFormat_2 = "";
try {
emsTimeFormat_2 = sdf_2.format(sdf_1.parse(emsTime));
} catch (ParseException e) {
e.printStackTrace();
}
System.out.println(emsTimeFormat_2); //打印标准格式解析的日期
System.out.println(emsTimeFormat_1); //打印最2格式解析的日期
}
}