[IGN-6614]What is the best way to format a date (milliseconds) for a specified timezone with Ignition's python scripting

Ah, I was overthinking things.

SimpleDateFormat extends DateFormat. DateFormat defines setTimeZone().

TimeZone is an instance of java.util.TimeZone, and easiest obtained from an ID.

from java.util import TimeZone
from java.text import SimpleDateFormat

#for tz in TimeZone.getAvailableIDs():
#	print tz

now = system.date.now()

eastern = TimeZone.getTimeZone("America/New_York")
pacific = TimeZone.getTimeZone("America/Los_Angeles")

sdf = SimpleDateFormat("yyyy-MM-dd HH:mm:ss ZZZ")
print sdf.getTimeZone().getID()
print sdf.format(now)

sdf.setTimeZone(eastern)
print sdf.getTimeZone().getID()
print sdf.format(now)

sdf.setTimeZone(pacific)
print sdf.getTimeZone().getID()
print sdf.format(now)

Here in California, that gets me:

>>> 
America/Los_Angeles
2022-09-14 11:43:14 -0700
America/New_York
2022-09-14 14:43:14 -0400
America/Los_Angeles
2022-09-14 11:43:14 -0700 
4 Likes