The withZoneSameInstant() method

Report a typo

What is the output of the last line of this code?

ZoneId yerevanZone = ZoneId.of("Asia/Yerevan");
ZoneId londonZone = ZoneId.of("Europe/London");

LocalDateTime localDateTime = LocalDateTime.of(1991, 4, 15, 18, 0);
ZonedDateTime londonZonedDateTime = ZonedDateTime.of(localDateTime, londonZone);

System.out.println(londonZonedDateTime.toInstant()); // 1991-04-15T17:00:00Z
System.out.println(ZoneOffset.from(localDateTime.atZone(yerevanZone))); // +04:00
System.out.println(londonZonedDateTime.withZoneSameInstant(yerevanZone));
Enter a short text
___

Create a free account to access the full topic