无法使用SimpleDateFormat解析日期格式

时间:2015-09-19 07:32:42

标签: java date simpledateformat

我有一个字符串" Thu Jan 01 01:32:49 EDT 1970"并尝试使用java.text.SimpleDateFormat

解析它
Exception in thread "main" java.text.ParseException: Unparseable date: "Thu Jan 01 01:32:49 EDT 1970"
    at java.text.DateFormat.parse(DateFormat.java:357)
    at Main.main(Main.java:8)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)ppMain.main(AppMain.java:134)

获得例外:

  1) Failure:
UsersLoginTest#test_login_with_invalid_information [/REDACTED/users_login_test.rb:32]:
expecting <"session/new"> but rendering with <["sessions/new", "layouts/application"]>


  2) Failure:
UsersEditTest#test_unsuccessful_edit [/REDACTED/test/integration/users_edit_test.rb:11]:
expecting <"users/edit"> but rendering with <[]>


  3) Failure:
UsersEditTest#test_successful_edit [/REDACTED/test/integration/users_edit_test.rb:22]:
expecting <"users/edit"> but rendering with <[]>

我无法理解,出了什么问题?

1 个答案:

答案 0 :(得分:4)

我认为这是一个$revs = array(); $allrevs = array(); while(mysqli_stmt_fetch($statement)){ $revs["item_name"] = $item_name; $revs["username"] = $username; $revs["review"] = $review; $allrevs[] = $revs; } echo json_encode($allrevs); 问题,因为代码对我有用。尝试:

Locale

DEMO