Find the offset between the Gateway Timezone and the session TimeZoneId

Is there a way to get the offset between the Gateway Timezone (UTC) and the timezoneid configured in the session props? What I'm trying to do is to read a json object that has a date as a string, with the time already in the local timezone. However, when I parse it, it gets "converted" to the local timezone. I was thinking I could get the offset between these timezones and add it to the datetime after parsing, but I can find no way to calculate this.

Ignition datetime objects are always UTC under the hood, and always converted to some time zone when stringified. If you want parse or stringify in some specific timezone, use java's ZonedDateTime and TimeZone classes directly, then convert to/from Ignition's java.util.Date.

Some reading on this topic:

https://forum.inductiveautomation.com/search?q=%40pturmel%20ZonedDateTime%20TimeZone%20order%3Alatest

In any case, adding or subtracting to a java.util.Date object to "correct" its time zone is always a bad idea.

I can see why this is a bad idea, what would be a better practice, in your opinion?

Do this.

Do not use strings of dates except when forced to, typically user input and user display. (Perhaps when handling web api traffic, but those typically use unambiguous ISO utc formats.) Everywhere else, work with the UTC-based java.util.Date objects.

Wherever you can, let Ignition's components apply a client timezone automatically. Sometimes this requires you to clearly identify datetime objects in ambiguous contexts, like table column rendering.