LocalTime constructor
Constructs a LocalTime instance from its components.
Throws an InvalidArgumentException if any input is outside valid ranges.
Example
final time = LocalTime(9, 15, 30, 500);
A value object representing a time of day without any date or timezone information.
LocalTime
is immutable and supports operations such as:
- Parsing from strings
- Formatting to strings
- Time arithmetic (addition/subtraction)
- Comparison and equality checks
This class is useful when working with:
- Scheduling systems
- Time pickers
- Representing specific times (like "08:30 AM") without a date context
Example
final time = LocalTime(14, 30); // 2:30 PM
final later = time.plusMinutes(45); // 3:15 PM
print(later); // 15:15:00
Implementation
LocalTime(this.hour, this.minute, [this.second = 0, this.millisecond = 0]) {
_validateTime(hour, minute, second, millisecond);
}