- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2019 07:12 AM
Hello,
I am getting value of date/time field in GMT format from one API and inserting that value to my table. I need to convert that GMT format into IST then I want to insert that value in my table.
Can anyone please help me with this.
Regards,
Nivedita
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2019 04:06 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2019 04:06 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2019 04:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2019 05:11 AM
I have updated my code like this :
var gdt = new GlideDateTime();
var tz = Packages.java.util.TimeZone.getTimeZone("GMT"); //sets to IST
gdt.setTZ(tz);
for(var i = 0; i<obj.plannedEvents.length; i++) {
var gr = new GlideRecord('u_tcl_plannedevents');
gr.addQuery('u_ticket_id', obj.plannedEvents[i].ticketId);
gr.query();
if (!gr.next()) {
gs.log("insert records");
gr.initialize();
var Event_start_date = obj.plannedEvents[i].plannedEventStartDate;
var Event_end_date = obj.plannedEvents[i].plannedEventEndDate;
gs.log("Start and end dates are "+Event_start_date+"---"+Event_end_date);
gdt.setValue(new GlideDateTime(Event_start_date));
gdt.setValue(new GlideDateTime(Event_end_date));
gr.u_plannedevent_start_date = gdt.getDisplayValue();
gr.u_plannedevent_end_date = gdt.getDisplayValue();
Please correct me if i am wrong.
Regards,
Nivedita

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2019 05:38 AM
Almost corect.
1 change is you put this line
gdt.setValue(new GlideDateTime(Event_end_date));
After
gr.u_plannedevent_start_date = gdt.getDisplayValue();
Alsoin logs, add a log after you assign to table field
gs.log(" converted date is "+ gdt.getDisplayValue());
and share the logs output.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2019 10:18 AM