- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2019 02:21 AM
We have a requirement where I need to get the Scheduled start and end dates from email body which is in UTC format(both past and future dates will be available in email body)and convert this to EST. After converting it into EST we need to capture it on Planned start and end dates fields on change request.
I tried below code in my Inbound action
var startdt= email.body.scheduled_start;
var gdt = new GlideDateTime(startdt);
gdt.addSeconds(-14400);
var enddt= email.body.scheduled_end;
var gdt1 = new GlideDateTime(enddt);
gdt1.addSeconds(-14400);
//gs.log("date end _2 "+gdt1.getValue());
current.start_date = gdt.getValue();
current.end_date= gdt1.getValue();
Above code works fine for now but I have to change the seconds in code (gdt.addSeconds(-14400);) twice in an year because EST has daylight saving.
Could anyone help me what code needs be placed instead of updating the seconds manually in the code during day light saving.
Thanks,
Divya Saridey
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2019 03:16 AM
Hello Try this
var startdt = new GlideDateTime(email.body.scheduled_start);
var tz = Packages.java.util.TimeZone.getTimeZone("America/New_York");
startdt.setTZ(tz);
var timeZoneOffSet = startdt.getTZOffset();
startdt.setNumericValue(startdt.getNumericValue() + timeZoneOffSet);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2019 05:07 AM
glad i could help