toYear

fun String.toYear(vararg formats: String?): Year?

Works off of String representations of Year (ISO default: "2024"). When formats are provided, each format is attempted in-order until one succeeds.

Return

Year? Null means couldn't parse, else parsed Year.

Parameters

this

String representation of Year.

formats

String? vararg of formats to attempt when parsing.