function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

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', ' '));