DateTimeConverter 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 = DateTimeConverter.toNullableDateTime('ABC'); // Result: null
var value2 = DateTimeConverter.toNullableDateTime('2018-01-01T11:30:00.0'); // Result: Date(2018,0,1,11,30)
var value3 = DateTimeConverter.toNullableDateTime(123); // Result: Date(123)

Constructors

DateTimeConverter()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

toDateTime(dynamic value) DateTime
Converts value into Date or returns current date when conversion is not possible.
toDateTimeWithDefault(dynamic value, DateTime defaultValue) DateTime
Converts value into Date or returns default when conversion is not possible.
toNullableDateTime(dynamic value) DateTime?
Converts value into Date or returns null when conversion is not possible.