I need to convert GMT date/time format into IST format.

niveditakumari
Mega Sage

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

1 ACCEPTED SOLUTION

Hi, It's bcoz your system timezone is ist. So while storing it is converting to ist. If you don't want that conversion then in our earlier code, Just change this line and uncomment the other lines. Packages.java.util.TimeZone.getTimeZone("IST"); //sets to IST TO Packages.java.util.TimeZone.getTimeZone("GMT"); //sets to GMT and check.

View solution in original post

42 REPLIES 42

AbhishekGardade
Giga Sage

Hello Nivedita,

setTZ(TimeZone timeZone)
Sets the time zone of the GlideDateTime object to be the specified time zone.

var tz = gs.getSession().getTimeZone();
var gdt = new GlideDateTime();
gdt.setTZ(tz);

Please mark as Correct Answer and Helpful, if applicable.
Thanks!
Abhishek Gardade
Hexaware Technologies

Thank you,
Abhishek Gardade

Thank you for your reply.

I have created one schedule job to insert the values into table So where I need to write this code?

 

Regards,

Nivedita

 

Hello,

I have created one schedule job to insert records into table So do I need to write code in schedule job.

Can anyone please help me with this.

 

Regards,

Nivedita

Hi Nivedita,

Can you share the script here?

In the script you need to do that.

Regards

Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader