Sample Code:
String timestamp = '2023-08-07T14:53:49Z'; timestamp = timestamp.replace('T', ' '); System.debug('Datetime ==> '+DateTime.valueOf(timestamp));