0

I am getting an error when I am executing this piece of code.

String ss_time = '2015-10-21T10:04:04.000Z'; 
c.Assignment_Start_Time__c =DateTime.valueOf(ss_time);

Error Message : System.TypeException: Invalid date/time: 2015-10-21T10:04:04.000Z

How should I set the datetime properly. Any help on this would be highly appreciated.

1

You can simply remove the T from the string value, for example:

String ss_time = '2015-10-21 10:04:04.000Z'; 
c.Assignment_Start_Time__c =DateTime.valueOf(ss_time);

Note that the returned value is in GMT, see documentation for details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.