public Date parseDate(String date){ SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); Date result = null; try { result = sdf.parse(date); } catch (ParseException ex) { log.logError("Date format must be MM/dd/yyyy HH:mm:ss"); } return result; }
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
Date result = null;
try {
result = sdf.parse(date);
} catch (ParseException ex) {
log.logError("Date format must be MM/dd/yyyy HH:mm:ss");
}
return result;
}
呢一般处理数据都是MM/dd/yyyy格式的啊
或MM/dd/yyyy格式。
当然你也可以通过重载,不过那个不提倡。
SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date=format.parse(mm);搞定