-2
在我的應用程序中我得到一個日期字符串'2017-08-08T07:32:24Z'我需要解析這個字符串日期。我寫了一個代碼爲無法解析字符串日期格式
String string = "2017-08-08T07:32:24Z";
DateFormat format = new SimpleDateFormat(" yyyy-MM-dd'T'HH:mm:ss'Z'");
Date date = format.parse(string);
上執行我得到了下面的錯誤代碼:
java.text.ParseException: Unparseable date: "2017-08-08T07:32:24Z"
at java.text.DateFormat.parse(Unknown Source)
at com.rapidvalue.accurate.utils.AutomationMail.getMailBodyData(AutomationMail.java:367)
at com.rapidvalue.accurate.utils.AutomationMail.sendMail(AutomationMail.java:205)
at com.rapidvalue.accurate.reporting.AutomationListener.onExecutionFinish(AutomationListener.java:1768)
at org.testng.TestNG.runExecutionListeners(TestNG.java:1158)
at org.testng.TestNG.run(TestNG.java:1123)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)
可以在此
[Java字符串到日期轉換(https://stackoverflow.com/questions/4216745/java-string-to-date-conversion) –
除去在空白的圖案的beginnig的可能重複: '「yyyy' – Jens
@Jens說右鍵刪除空格,它會起作用 –