/**
* 将String类型转化为Date
时间格式
* @param str
* @param id
* @return
*/
public static Date ToDateTime(String str, int id) {
SimpleDateFormat format = null;
switch (id) {
case 1:
format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
break;
case 2:
format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
break;
case 3:
format = new SimpleDateFormat("yyyy年MM月dd日HH:mm:ss");
break;
case 4:
format = new SimpleDateFormat("yyyy-MM-dd");
break;
}
Date date = null;
try {
date = format.parse(str);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}