compareTo method
- TimeOfDay other
override
Compares this TimeOfDay object to other
independent of date.
Does not account for day or sub-minute differences. This means that "00:00" of the next day is still before "23:00" of this day.
A compareTo function returns:
- a negative value if this TimeOfDay isBefore
other
. 0
if this DateTime isAtSameTimeAsother
, and- a positive value otherwise (when this TimeOfDay isAfter
other
).
Implementation
@override
int compareTo(TimeOfDay other) {
final int hourComparison = hour.compareTo(other.hour);
return hourComparison == 0 ? minute.compareTo(other.minute) : hourComparison;
}