LocalTime.fromMillisecondOfDay constructor
LocalTime.fromMillisecondOfDay(
- int millisecondOfDay
Creates a LocalTime from the number of milliseconds since midnight.
Values are normalized to the range of a 24-hour day (0 to 86,399,999). 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
factory LocalTime.fromMillisecondOfDay(int millisecondOfDay) {
final hour = millisecondOfDay ~/ (60 * 60 * 1000);
final minute = (millisecondOfDay % (60 * 60 * 1000)) ~/ (60 * 1000);
final second = (millisecondOfDay % (60 * 1000)) ~/ 1000;
final millisecond = millisecondOfDay % 1000;
return LocalTime(hour, minute, second, millisecond);
}