I want to Convert America/Phoenix to GMT
ZonedDateTime zdtPhoenix1 = ZonedDateTime.of(2022, 6, 27, 10, 0, 0, 0, ZoneId.of("America/Phoenix"));
System.out.println(zdtPhoenix1);
System.out.println(zdtPhoenix1.withZoneSameInstant(ZoneId.of("GMT")));
Out Put
2022-06-27T10:00-07:00[America/Phoenix]
2022-06-27T17:00Z[GMT]
I am expecting GMT
2022-06-27T03:00Z[GMT]
As ZoneOffset of America/Phoenix is -7 hours but the actual output is +7 hours
>Solution :
10:00-07:00 is not an arithmetic expression.
-07:00 means that your clock is 7 hours behind GMT. So that means that when it is 10 o’clock in GMT, 10 o’clock in America/Phoenix will be 7 hours later.
So yes, if it’s 10:00 in America/Phoenix, then it’s already 17:00 in GMT.