2

Can anyone explain what is so erroneous about this date?

Class.SMSCallbackController.doGet: line 42, column 1
14:55:07.039 (39781770)|FATAL_ERROR|System.TypeException: Invalid date/time: 2014-06-16T15:55:00Z

It's in EXACTLY the same format as the one on the documentation.

If it helps, the date is received like this: "2014-06-16T15:55:00.000", but I take the first 19 characters out using .substring() and append a 'Z' to the end before doing Datetime.valueOf(date_as_string).

4

1 Answer 1

2

The Documentation says that the format of the string passed to Datetime.valueOf should be 'yyyy-MM-dd HH:mm:ss'. So maybe that's why it gave you an error.

https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_datetime.htm#apex_System_Datetime_valueOf

I have also used the JSON deserlialize to get the date time, as shown below. You could use that as well.

System.debug((datetime)json.deserialize('"2014-06-16T15:55:00.000Z"', datetime.class));

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .