Android parse String to Date - unknown pattern character 'X'

前端 未结 13 1057
耶瑟儿~
耶瑟儿~ 2021-01-31 07:32

I have Service fetch date string from web and then I want to pare it to Date object. But somehow application crashes. This is my string that I\'m parsi

13条回答
  •  暖寄归人
    2021-01-31 07:49

    You are using the wrong date formatter.

    Use this instead: DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");

    I think that android in contrast with Java 7 uses Z (as in Java 6) for timezones and not X. So, use this for your date formats.

提交回复
热议问题