You need to sign in to do that
Don't have an account?
Eric Blaxton 11
How to deal with APEX DATE TIME type exceptions
Hello and thanks in advance,
I am trying to store a DateTime value in a DateTime variable. I've tried the valueofGMT and got an error also.
Returned Value from HTTP request:
Line causing fatal error:
Error Code:
Eric
I am trying to store a DateTime value in a DateTime variable. I've tried the valueofGMT and got an error also.
Returned Value from HTTP request:
"reportDate":"2020-11-04T13:51:16.4718777-06:00"
Line causing fatal error:
Datetime reportDate= Datetime.valueOf(valueMap.get('reportDate'));
Error Code:
10:00:25:056 FATAL_ERROR System.TypeException: Invalid date/time: 2020-11-04T13:49:57.3103458-06:00Regards,
Eric
Greetings!
To parse DateTimes in this ISO format, you need to use JSON deserialization.
The JSON parser understands ISO format, while DateTime.parse() uses the running user's locale settings.
Reference:https://salesforce.stackexchange.com/questions/247210/system-typeexception-invalid-date-time-2019-01-03t002601-711-0200
Kindly mark it as best answer if it helps so that it can help others in the future.
Warm Regards,
Shirisha Pathuri
All Answers
Greetings!
To parse DateTimes in this ISO format, you need to use JSON deserialization.
The JSON parser understands ISO format, while DateTime.parse() uses the running user's locale settings.
Reference:https://salesforce.stackexchange.com/questions/247210/system-typeexception-invalid-date-time-2019-01-03t002601-711-0200
Kindly mark it as best answer if it helps so that it can help others in the future.
Warm Regards,
Shirisha Pathuri
Thank you for your time and help.
Here's the end result.
Eric