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
Jack D PondJack D Pond 

Convert internet date/time String to DateTime

Webhooks and Web services often use ietf Internet Date/Time strings (IETF Date and Time on the Internet: Timestamps: Examples (https://xml2rfc.tools.ietf.org/public/rfc/html/rfc3339.html#date.and.time.format.examples))

Most commonly, the format '2021-03-25T12:26:00.00Z'
However, 

Datetime xPassedTime = Datetime.valueOf('2021-03-25T12:26:00.00Z');
will return an error of "System.TypeException: Invalid date/time: 2021-03-25T12:26:00.0000Z"
However, if you change the 'T' to a space, it works fine.  Example:
Datetime xPassedTime = Datetime.valueOf('2021-03-25T12:26:00.00Z'.replace('T',' '));
Bizarrely, the JSONParser getDatetimeValue() works just fine with the standard format.
Q1: Am I going about this correctly?
Q2: Is this an enhancement request or bug?
Q3: Is the .replace('T',' ') a best-practice workaround (and if so, mark this as answer).