LocalTime class

LocalTime is an immutable class representing a time of day, with no reference to a particular calendar, time zone or date.

Implemented types
Annotations
  • @immutable

Constructors

LocalTime(int hour, int minute, int second, {int? ms, int? us, int? ns})
Creates a local time at the given hour, minute, second and millisecond or microseconds or nanoseconds within the second.
factory
LocalTime.currentClockTime()
Produces a LocalTime based on your Clock.current and your DateTimeZone.local.
factory
LocalTime.sinceMidnight(Time time)
Factory method for creating a local time from the number of ticks which have elapsed since midnight.
factory

Properties

hashCode int
Returns a hash code for this local time.
no setteroverride
hourOf12HourClock int
Gets the hour of the half-day of this offset time, in the range 1 to 12 inclusive.
no setter
hourOfDay int
Gets the hour of day of this offset time, in the range 0 to 23 inclusive.
no setter
microsecondOfSecond int
Gets the microsecond of this local time within the second, in the range 0 to 999,999 inclusive.
no setter
millisecondOfSecond int
Gets the millisecond of this offset time within the second, in the range 0 to 999 inclusive.
no setter
minuteOfHour int
Gets the minute of this offset time, in the range 0 to 59 inclusive.
no setter
nanosecondOfSecond int
Gets the nanosecond of this offset time within the second, in the range 0 to 999,999,999 inclusive.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
secondOfMinute int
Gets the second of this offset time within the minute, in the range 0 to 59 inclusive.
no setter
timeSinceMidnight → NanosecondTime
Nanoseconds since midnight, in the range [0, 86,400,000,000,000). ~ 46 bits
final

Methods

add(Period period) LocalTime
Adds the specified period to this time. Fluent alternative to operator+().
addHours(int hours) LocalTime
Returns a new LocalTime representing the current value with the given number of hours added.
addMicroseconds(int microseconds) LocalTime
Returns a new LocalTime representing the current value with the given number of microseconds added.
addMilliseconds(int milliseconds) LocalTime
Returns a new LocalTime representing the current value with the given number of milliseconds added.
addMinutes(int minutes) LocalTime
Returns a new LocalTime representing the current value with the given number of minutes added.
addNanoseconds(int nanoseconds) LocalTime
Returns a new LocalTime representing the current value with the given number of nanoseconds added.
addSeconds(int seconds) LocalTime
Returns a new LocalTime representing the current value with the given number of seconds added.
adjust(LocalTime adjuster(LocalTime)) LocalTime
Returns this time, with the given adjuster applied to it.
atDate(LocalDate date) LocalDateTime
Combines this LocalTime with the given LocalDate into a single LocalDateTime. Fluent alternative to operator+().
compareTo(LocalTime? other) int
Indicates whether this time is earlier, later or the same as another one.
override
equals(LocalTime other) bool
Compares this local time with the specified one for equality, by checking whether the two values represent the exact same local time, down to the tick.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
periodSince(LocalTime time) Period
Subtracts the specified time from this time, returning the result as a Period. Cognitively similar to: this - time.
periodUntil(LocalTime time) Period
Subtracts the specified time from this time, returning the result as a Period. Cognitively similar to: time - this.
subtract(Period period) LocalTime
Subtracts the specified period from this time. Fluent alternative to operator-().
subtractHours(int hours) LocalTime
subtractMicroseconds(int microseconds) LocalTime
subtractMilliseconds(int milliseconds) LocalTime
subtractMinutes(int minutes) LocalTime
subtractNanoseconds(int nanoseconds) LocalTime
subtractSeconds(int seconds) LocalTime
toString([String? patternText, Culture? culture]) String
Formats the value of the current instance using the specified pattern.
override
withOffset(Offset offset) OffsetTime
Returns an OffsetTime for this time-of-day with the given offset.

Operators

operator +(Period period) LocalTime
Creates a new local time by adding a period to an existing time. The period must not contain any date-related units (days etc) with non-zero values.
operator -(Period period) LocalTime
Creates a new local time by subtracting a period from an existing time. The period must not contain any date-related units (days etc) with non-zero values. This is a convenience operator over the Minus(Period) method.
operator <(LocalTime other) bool
Compares two LocalTime values to see if the left one is strictly earlier than the right one.
operator <=(LocalTime other) bool
Compares two LocalTime values to see if the left one is earlier than or equal to the right one.
operator ==(Object other) bool
Compares two local times for equality, by checking whether they represent the exact same local time, down to the tick.
override
operator >(LocalTime other) bool
Compares two LocalTime values to see if the left one is strictly later than the right one.
operator >=(LocalTime other) bool
Compares two LocalTime values to see if the left one is later than or equal to the right one.

Static Properties

maxValue LocalTime
The maximum value of this type, one nanosecond before midnight.
final
midnight LocalTime
Local time at midnight, i.e. 0 hours, 0 minutes, 0 seconds.
final
minValue LocalTime
The minimum value of this type; equivalent to midnight.
final
noon LocalTime
Local time at noon, i.e. 12 hours, 0 minutes, 0 seconds.
final

Static Methods

difference(LocalTime end, LocalTime start) Period
Subtracts the specified time from this time, returning the result as a Period. Fluent alternative to operator-().
max(LocalTime x, LocalTime y) LocalTime
Returns the later time of the given two.
min(LocalTime x, LocalTime y) LocalTime
Returns the earlier time of the given two.
minus(LocalTime time, Period period) LocalTime
Subtracts the specified period from the time. Friendly alternative to operator-().
plus(LocalTime time, Period period) LocalTime
Adds the specified period to the time. Friendly alternative to operator+().