DurationParser class
Parses a duration string into a Duration object.
The input string must be a number followed by an optional unit which is one of: seconds (s), minutes (m), hours (h), days (d), milliseconds (ms), or microseconds (us). If no unit is specified, the defaultUnit is assumed, which is in seconds if not specified otherwise. Examples:
10, equivalent to10s10m10h10d10ms10us
Throws FormatException if parsing failed.
- Inheritance
-
- Object
- ValueParser<
Duration> - DurationParser
Constructors
- DurationParser({DurationUnit defaultUnit = DurationUnit.seconds})
-
const
Properties
- defaultUnit → DurationUnit
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
format(
Duration value) → String -
Returns a usage documentation friendly string representation of the value.
The default implementation simply invokes toString.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
parse(
String value) → Duration -
Converts a source string value to the specific option value type.
Must throw a FormatException with an appropriate message
if the value cannot be parsed.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited