+ Start a Discussion
Eric Blaxton 11Eric Blaxton 11 

Deserialize JSON String Date to DateTime

Hi and thanks in advance.
My goal is to speed up an area of my apex class.  I was told that deserializing in a loop causes drag.  

I can successfully deserialize a JSON string Date to a DateTime value like this:
reportDate= (DateTime)JSON.deserialize('"' + valueMap.get('reportDate') + '"', DateTime.class);
I tried using DateTime.valueof like this:
reportDate= datetime.valueof(valueMap.get('reportDate'));
Here's the error I get:
Line: 74, Column: 1
System.TypeException: Invalid date/time: 2020-12-28T11:33:31-06:00


ShirishaShirisha (Salesforce Developers) 
Hi Eric,


Please refer this for more information related to this error.


Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri