toDateOrNull
Produce a date from the given strings value and pattern if possible.
Example:
"8/7/2022".toDateOrNull("MM/dd/yyyy") // Sun Aug 07 00:00:00 IRDT 2022
"Sun Aug 07 16:37:42 IRDT 2022".toDateOrNull() // Sun Aug 07 16:37:42 IRDT 2022
"7/2022".toDateOrNull("MM/dd/yyyy") // null
Content copied to clipboard
Since
1.1.0
Return
A nullable Date parsed from the string.