我試圖使用的SimpleDateFormat類來分析一個DateTime出這個字符串:爲什麼這個代碼生成錯誤:「無法解析的日期」
Mon Jan 10 2011 01:15:00 GMT+0000 (GMT Standard Time)
我試過如下格式的字符串:
String example = "Mon Jan 10 2011 01:15:00 GMT+0000 (GMT Standard Time)";
SimpleDateFormat formatter = new SimpleDateFormat("E M d y H:m:s z");
try
{
Date exampleDate = formatter.parse(example);
LOGGER.warn(exampleDate.toString());
}
catch(Exception e)
{
LOGGER.warn(e.getMessage(), e);
}
但它產生的錯誤:
Unparseable date: "Mon Jan 10 2011 01:15:00 GMT+0000 (GMT Standard Time)"
所以我試圖消除考試的括號內的端部ple字符串:
String example = "Sun Jan 09 2011 22:00:00 GMT+0000";
但它會產生相同的錯誤。
WARNING: Unparseable date: "Sun Jan 09 2011 22:00:00 GMT+0000"
java.text.ParseException: Unparseable date: "Sun Jan 09 2011 22:00:00 GMT+0000"
有關如何解決此問題的任何提示?
'EE MMM dŸH:M:S「GMT'z'爲我工作。 – mleonard