String格式:年月日时分秒毫秒
转换后String格式:年月日时分秒
Code:
/**
* 时间日期转换
* @param strDate 字符串
* @return 字符串yyyy-MM-dd HH:mm:ss
*/
public static String strToDateLong(String strDate) {
Date date = new Date();
try {
date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").parse(strDate);
} catch (ParseException e) {
e.printStackTrace();
}
String str = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
return str;
}