Java Time Zone When Parsing DateFormat

后端 未结 7 1663
梦谈多话
梦谈多话 2020-12-06 17:20

I had code that parses date as follows:

String ALT_DATE_TIME_FORMAT = \"yyyy-MM-dd\'T\'HH:mm:ss.SSSZ\";
SimpleDateFormat sdf = new SimpleDateFormat(
                 


        
相关标签:
7条回答
  • 2020-12-06 17:58

    The other application is using the ISO 8601 dateTime format. I am assuming the other application is sending you an XML response that is in compliance with XML Schema's dateTime type, which is ISO 8601. Now, it is a known thing that the DateFormat can't parse this format. You either have to use other libraries like joda-time (joda-time is the winner) or the FastDateFormat as specified in the other responses. Look at this post Converting ISO 8601-compliant String to java.util.Date

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