我传递的字符串如“2012-02-20'T'01:01:01”
/**
* Parse a workflowDate.
* @param workflowDate an instance of a workflowDate string.
* @return the date object containing parsed workflow date.
*/
private Date parseDate(final String workflowDate)
{
DateFormat df = new SimpleDateFormat("YYYY-MM-DD'T'hh:mm:ss", Locale.ENGLISH);
Date retVal = null;
try
{
retVal = df.parse(workflowDate);
}
catch (ParseException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
return retVal;
}
答案 0 :(得分:3)
使用yyyy-MM-dd'T'hh:mm:ss
格式代替YYYY-MM-DD'T'hh:mm:ss
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss", Locale.ENGLISH);