Unable to obtain ZonedDateTime from TemporalAccessor using DateTimeFormatter and ZonedDateTime in Java 8

后端 未结 5 1725
礼貌的吻别
礼貌的吻别 2020-11-30 11:11

I recently moved to Java 8 to, hopefully, deal with local and zoned times more easily.

However, I\'m facing an, in my opinion, simple problem when parsing a simple d

5条回答
  •  遥遥无期
    2020-11-30 11:15

    If coming from Google:

    Instead of doing:

    ZonedDateTime.from(new Date().toInstant());
    

    Try this:

    ZonedDateTime.ofInstant(new Date(), ZoneId.of("UTC")); 
    

提交回复
热议问题