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
Abhinav Pandey 25Abhinav Pandey 25 

How can I check if a given string is a DateTime String?

I want to ask if there is a method in Salesforce for checking if a given string is a DateTime format string?
@GM@GM
Use parse method to convert string into date format.
Date.ValueOf() does not accept null value as its input parameter.
The format of the String depends on the local date format.Try giving date in the format yyyy-mm-dd. It should work.

Example : 
String abc = '03/03/1990';
System.debug('Gm '+ date.parse(abc));

To check string , 
Date d = String.isBlank(str)  ? null : Date.valueOf(str);  

More info : https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_date.htm