Convert iso8601 string date time format to date in Java [duplicate]

心不动则不痛 提交于 2019-12-03 20:56:21

No, using SimpleDateFormat, parsing this date is not possible (at least not in jdk 6 or lower). We had to write our own adapter for this ourselves.

Note, since this format is a valid part of XML Schema, you can use the DatatypeConverter.parseDateTime() method to parse this date.

James Gardiner

The best answer I have found is on this question.

Converting ISO 8601-compliant String to java.util.Date

Quote: The easier solution is possibly to use the data type converter in JAXB, since JAXB must be able to parse ISO8601 date string according to the XML Schema specification. javax.xml.bind.DatatypeConverter.parseDateTime("2010-01-01T12:00:00Z") will give you a Calendar object and you can simply use getTime() on it, if you need a Date object.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!