+ Start a Discussion
SheedSheed 

Conversion of String to DateTime format in Salesforce

I need to convert a string that I am getting from JSON response (For eg: 2018-05-29T22:57:11.000-07:00) to DateTime  (eg:2014-03-29 06:09:36) 

what should i do?
Shravan Kumar 71Shravan Kumar 71
Hello Sheed,

Please try the below code and let us know if it works :

String dateString = '2018-05-29T22:57:11.000-07:00';
DateTime resultDateTime = DateTime.ValueofGmt(dateString.replace('T', ' '));

Thanks,
Shravan