Hi all. I'm trying to convert an instant from local time zone (e.g. America/New_York) to UTC (with offset) which should be (at this moment in time) +5 hours. When I'm trying to calculate offset in time zone UTC I get no change (printing it shows "Z"). How can I convert from local time zone adjusted to UTC where the delta is taken into account properly? It seems right now, whatever the instant is it will just be used as is but with UTC with no datetime change.
s
Sam
12/11/2024, 3:49 PM
Can you share an example?
a
Alexandru Gheorghe
12/11/2024, 3:50 PM
As in code or simply use case?
s
Sam
12/11/2024, 3:51 PM
What's an example input, and what output do you want for that input?
d
Dmitry Khalanskiy [JB]
12/11/2024, 3:53 PM
You can't convert an instant from a local time zone to anything, because instants are independent of time zones.
finds the instant corresponding to when clocks in New York show 2024-12-11 08:29 AM and then finds what clocks in the UTC time zone show at that instant.