Date.parse to convert a String to a Date

Constructs a Date from a String. The format of the String depends on the local date format.


Date testDate = Date.parse('01/01/2022');

system.debug(testDate);



Output - 2022-01-01T00:00:00.000Z


Reference:https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_date.htm#apex_System_Date_parse


Visual : https://www.youtube.com/watch?v=6b1WdlqzZSY

Comments