toDate¶
common
Converts a string to a Date.
The string is assumed to be an ISO-8601 calendar date in extended format. For example, 2010-10-05
. The output of Date.toString can be safely parsed using this method.
Throws¶
DateTimeParseException | if parsing fails |
DateTimeException | if the parsed date is invalid |
common
fun String.toDate(parser: DateTimeParser, settings: DateTimeParserSettings = DateTimeParserSettings.DEFAULT): Date
Converts a string to a Date using a specific parser.
A set of predefined parsers can be found in DateTimeParsers.
Any custom parser must be capable of supplying one of the following field combinations:
- [DateTimeField.YEAR](../io.islandtime.base/-date-time-field/-y-e-a-r/index.md), [DateTimeField.MONTH_OF_YEAR](../io.islandtime.base/-date-time-field/-m-o-n-t-h_-o-f_-y-e-a-r/index.md), [DateTimeField.DAY_OF_MONTH](../io.islandtime.base/-date-time-field/-d-a-y_-o-f_-m-o-n-t-h/index.md)
- [DateTimeField.YEAR](../io.islandtime.base/-date-time-field/-y-e-a-r/index.md), [DateTimeField.DAY_OF_YEAR](../io.islandtime.base/-date-time-field/-d-a-y_-o-f_-y-e-a-r/index.md)
Throws¶
DateTimeParseException | if parsing fails |
DateTimeException | if the parsed date is invalid |