The CreatorCon Call for Content is officially open! Get started here.

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

niveditakumari
Mega Sage

Hello,

Can anyone please help me with this.

 

Regards,

Nivedita

Hi, Chk my reply.

Please use this

var start = new GlideDateTime(current.start_date);// current.start_date is a field where time is need to be converted
var tz = Packages.java.util.TimeZone.getTimeZone("US/Eastern");  // replace it with IST
start.setTZ(tz);
var timeZoneOffSet = start.getTZOffset();
start.setNumericValue(start.getNumericValue() + timeZoneOffSet);