toDateTime property
DateTime?
toDateTime
Converts this number to a DateTime object based on the number of digits.
Example:
print(1609459200000.toDateTime); // Output: 2021-01-01 00:00:00.000 (assuming milliseconds)
print(1609459200000000.toDateTime); // Output: 2021-01-01 00:00:00.000 (assuming microseconds)
Implementation
DateTime? get toDateTime {
if (numberOfDigits == 13) {
return DateTime.fromMillisecondsSinceEpoch(toInt());
} else if (numberOfDigits == 16) {
return DateTime.fromMicrosecondsSinceEpoch(toInt());
}
return null;
}