/**
* 将string转换为yyyyMMddHHmmss格式的Date型
* @param time
* @return java.util.Date
*/
public static Date convertStringToDate(String time) {
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss"); Date date = null; if (time != null && !"".equals(time)) { try { date = format.parse(time); } catch (Exception e) { System.out.println(e.getMessage()); } } return date; } /** * 将Date型格式化yyyy-MM-dd HH:mm:ss String * @param date * @return String (yyyy-MM-dd HH:mm:ss) */ public static String convertDateToString(Date date){ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String strDate = format.format(date); return strDate; }