SimpleDateFormat ignores “XXX” if timezone is set to “UTC”

↘锁芯ラ 提交于 2019-12-04 07:04:42

See the documentation for SimpleDateFormat:

For formatting [using an ISO 8601 Time zone], if the offset value from GMT is 0, "Z" is produced.

So, this behaviour is expected.

You can either:

  • Use the RFC 822 timezone formatter ZZZ; however, this produces "+0000"
  • Manipulate the string to replace the final Z: str.replaceAll("Z$", "+00:00")
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!