Convert ZonedDateTime to LocalDateTime at time zone

前端 未结 4 1996
傲寒
傲寒 2020-12-28 15:42

I have an object of ZonedDateTime that is constructed like this

ZonedDateTime z = ZonedDateTime.of(LocalDate.now().atTime(11, 30), ZoneOffset.UT         


        
4条回答
  •  我在风中等你
    2020-12-28 16:02

    Try this out. Substitute US/Central with your timezone.

    ZonedDateTime z = ZonedDateTime.of(LocalDate.now().atTime(11, 30), ZoneOffset.UTC);
    
    System.out.println(z.withZoneSameInstant(ZoneId.of("US/Central")));
    

提交回复
热议问题