DurationConverter class

Converts arbitrary values into Date values using extended conversion rules:

  • Strings: converted using ISO time format
  • Numbers: converted using milliseconds since unix epoch

Example

var value1 = DurationConverter.toNullableDuration('ABC'); // Result: null
var value2 = DurationConverter.toNullableDuration('123'); // Result: Duration(milliseconds: 123)
var value3 = DurationConverter.toNullableDuration(123); // Result: Duration(milliseconds: 123)

Constructors

DurationConverter()

Properties

hashCode → int
The hash code for this object. [...]
read-only, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() → String
Returns a string representation of this object.
inherited

Operators

operator ==(dynamic other) → bool
The equality operator. [...]
inherited

Static Methods

toDuration(dynamic value) → Duration
Converts value into Date or returns current date when conversion is not possible. [...]
toDurationWithDefault(dynamic value, Duration defaultValue) → Duration
Converts value into Date or returns default when conversion is not possible. [...]
toNullableDuration(dynamic value) → Duration
Converts value into Date or returns null when conversion is not possible. [...]