toLocalTimeOrNull

fun String.toLocalTimeOrNull(pattern: String = "EEE MMM dd HH:mm:ss zzz yyyy"): LocalTime?

Produce a LocalTime from the given strings value and pattern if possible.

Example:

"21->15->0".toLocalTime("HH->mm->ss") // 21:15
"Sun Aug 07 16:37:42 IRDT 2022".toLocalTime() // 16:37:42
"21:10:00".toLocalTime("HH::mm") // null

Since

1.1.0

Return

A nullable LocalTime parsed from the string.

See also