fork(2) download
  1. import java.time.LocalDate;
  2. import java.time.LocalDateTime;
  3. import java.time.LocalTime;
  4. import java.time.ZoneId;
  5. import java.time.ZonedDateTime;
  6.  
  7. public class Main {
  8. public static void main(String[] args) {
  9. // The given ZonedDateTime
  10. ZonedDateTime zdtAbidjan = ZonedDateTime.of(
  11. LocalDateTime.of(LocalDate.of(2021, 9, 16),
  12. LocalTime.of(12, 0)),
  13. ZoneId.of("Africa/Abidjan")
  14. );
  15. System.out.println(zdtAbidjan);
  16.  
  17. ZonedDateTime zdtLondon = zdtAbidjan.withZoneSameInstant(ZoneId.of("Europe/London"));
  18. System.out.println(zdtLondon);
  19. }
  20. }
Success #stdin #stdout 0.12s 51748KB
stdin
Standard input is empty
stdout
2021-09-16T12:00Z[Africa/Abidjan]
2021-09-16T13:00+01:00[Europe/London]