Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

ZonedDateTime America/Phoenix zone to GMT having issue

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading