I need to parse Durations from strings. Java 8 provide a method for that taking the ISO-8601 standard as a basis:
Duration.parse("p10d"); // parses as ten days
Duration.parse("pt1h"); // parses as one hour
As the standard states that "it is permitted to omit the 'T' character by mutual agreement" some of the Javadoc examples of Durations.parse() leave out the T
. According to them, the following expression should parse as "-6 hours and +3 minutes":
"P-6H3M"
But I found that all expressions ommitting the T
throw a DateTimeParseException
. Is that a bug in the parse()
method or am I missing something?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With