GlideDateTime setTZ(TimeZone timeZone) does NOT work

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2020 06:49 AM
According to this: setTZ(TimeZone timeZone)
It's not working.
Step 1, change your profile timezone:
Step 2, run this background script:
var tz = gs.getSession().getTimeZone();
gs.print(tz);
var gdt = new GlideDateTime();
gs.print(gdt);
gdt.setTZ(tz);
gs.print(gdt);
Step 3, view the results:
*** Script: sun.util.calendar.ZoneInfo[id="America/Anchorage",offset=-32400000,dstSavings=3600000,useDaylight=true,transitions=142,lastRule=java.util.SimpleTimeZone[id=America/Anchorage,offset=-32400000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]]
*** Script: 2020-07-27 13:36:28
*** Script: 2020-07-27 13:36:28
Now, repeat the steps but using different time zones:
Result:
*** Script: sun.util.calendar.ZoneInfo[id="America/New_York",offset=-18000000,dstSavings=3600000,useDaylight=true,transitions=235,lastRule=java.util.SimpleTimeZone[id=America/New_York,offset=-18000000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]]
*** Script: 2020-07-27 13:37:20
*** Script: 2020-07-27 13:37:20
So why does SN think that Anchorage Alaska has the same time as New York???
1 REPLY 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2020 07:11 AM
Hi
You need to use gdt.getDisplayValue() to get the converted value. Just using gdt will return the actual value (not the converted one).
Mark the comment as a correct answer and helpful if it answers your question.