异常: at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) Caused by: java.text.ParseException: Failed to parse date ["2019-03-13 00:00:00"]: Invalid time zone indicator ' ' at com.google.gson.internal.bind.util.ISO8601Utils.parse(ISO8601Utils.java:274) at com.google.gson.internal.bind.DateTypeAdapter.deserializeToDate(DateTypeAdapter.java:85) ... 42 more Caused by: java.lang.IndexOutOfBoundsException: Invalid time zone indicator ' ' at com.google.gson.internal.bind.util.ISO8601Utils.parse(ISO8601Utils.java:245) ... 43 more
方案:
Gson gson = new GsonBuilder() .setDateFormat("yyyy-MM-dd HH:mm:ss") .create(); List<TrackTempPO> orderStatus = gson.fromJson(dada, new TypeToken<List<TrackTempPO>>() {}.getType());