+ 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