java.time.format.DateTimeParseException: Unable to obtain ZonedDateTime from TemporalAccessor on format ddMMyyyyhhmmss [duplicate]

笑着哭i 提交于 2019-12-02 03:59:43

You want :

  String test = ZonedDateTime.now().format(formatter);

ddMMyyyyhhmmss does not contain any zone information, it's not ZonedDateTime, it should be LocalDateTime.

In the string you parse, there is no information about the TimeZone - so how should the Formatter know how to transer into ZonedDateTime?

You either need to have the TimeZone information in your string, or use another Object to parse it into which has no TimeZone infomation and afterwards transfer it into the Zone you need.

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