toYear

fun YearMonth.toYear(): Year

Returns this year-month with the precision reduced to the year.

fun Date.toYear(): Year

Returns this date with the precision reduced to the year.

fun DateTime.toYear(): Year
fun OffsetDateTime.toYear(): Year
fun ZonedDateTime.toYear(): Year

Returns this date-time with the precision reduced to the year.

fun String.toYear(): Year

Converts a string to a Year.

The string is assumed to be an ISO-8601 year. For example, 2010, +002010, or Y12345. The output of Year.toString can be safely parsed using this method.

Throws

fun String.toYear(parser: DateTimeParser, settings: DateTimeParserSettings = DateTimeParserSettings.DEFAULT): Year

Converts a string to a Year using a specific parser.

A set of predefined parsers can be found in DateTimeParsers.

The parser must be capable of supplying DateTimeField.YEAR.

Throws