'ZonedDateTime is returning same String for two different Timezone
I am trying to format current timestamp into two different time zone, But ZonedDateTime format is returning same output.
DateTimeFormatter outputFormat = new DateTimeFormatterBuilder().appendPattern("ddMMMyyyy HH:mm:ss").toFormatter();
System.out.println(ZonedDateTime.of(LocalDateTime.now(), ZoneId.of("America/Phoenix")).format(outputFormat));
System.out.println(ZonedDateTime.of(LocalDateTime.now(), ZoneId.of("Asia/Calcutta")).format(outputFormat));
above code snipped is returning same time stamp as
16Apr2022 13:28:19
16Apr2022 13:28:19
Can some one help me understand but its returning same String. What is correct way to format time in different time zone, using Java 8 Date Time APIs.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
