parsePeriodQuiet
The parsePeriodQuiet
method returns the string argument as a Period, which is a unit of time in terms of calendar time (days, weeks, months, years).
"Quiet" methods return null
instead of throwing an exception when encountering a string that cannot be parsed.
Syntax
parsePeriodQuiet(s)
Parameters
Parameter | Type | Description |
---|---|---|
s | string | The string to be converted. Date-time strings are formatted according to the ISO-8601 duration format as Examples:
|
Returns
A Period, or null
if invalid input is given.
Examples
period = parsePeriodQuiet("P33Y4M23D")
invalid_period = parsePeriodQuiet("invalid")
println period
println invalid_period
- Log