The date format issue from java

后端 未结 1 403
囚心锁ツ
囚心锁ツ 2021-01-20 06:54

I get the date format from a joynet cloud api server:

2012-11-20T10:26:04+00:00\"

However, I have no idea to handle the last segment

1条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-20 07:18

    Remove that : inside the time zone part if you are not using java 7

    and use this :

    SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");

    See javadoc for SimpleDateFormat in Java 6

    And

    If you are using Java 7 then directly use this :

    SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX");

    See javadoc for SimpleDateFormat in Java 7

    0 讨论(0)
提交回复
热议问题