toString method
Returns a string representation of this Duration.
Returns a string with hours, minutes, seconds, and microseconds, in the
following format: H:MM:SS.mmmmmm
. For example,
var d = const Duration(days: 1, hours: 1, minutes: 33, microseconds: 500);
print(d.toString()); // 25:33:00.000500
d = const Duration(hours: 1, minutes: 10, microseconds: 500);
print(d.toString()); // 1:10:00.000500
Implementation
@override
String toString([String separator = ":"]) {
final m = minutesAs2D;
final s = secondsAs2D;
if (hours > 0) {
return "$hoursAs2D$separator$m$separator$s";
} else {
return "$m$separator$s";
}
}