我遇到时间戳问题。我得到String:2014-09-20 18:49:48.773829+00:00
,我需要从这个字符串中获取Timestamp。当我使用Timestamp.valueof(String)
时,我得到:
java.lang.IllegalArgumentException: Timestamp format must be yyyy-MM-dd HH:mm:ss.fffffffff; was '2014-09-20 18:49:48.773829+00:00'
at java.sql.Timestamp.badTimestampString(Timestamp.java:507)
at java.sql.Timestamp.valueOf(Timestamp.java:467)
at com.android.volley.toolbox.JsonRequest.deliverResponse(JsonRequest.java:65)
at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
如何从字符串中获取时间戳?
答案 0 :(得分:0)
答案可能在第一个字符串中 - Timestamp format must be yyyy-MM-dd HH:mm:ss.fffffffff.
否则你将得到解析异常。