TimeFormat class

Allows a Time to be formatted.

See UnitOfMeasurementFormat for general notes on the pattern syntax, which you can combine with the TimeUnit pattern specifiers as required:

Specifier Description
ns nanosecond
μs microsecond
ms millisecond
cs centisecond
ds decisecond
s second
das decasecond
min minute
hr hour
d day
wk week
fn fortnight
mo month
qr quarter
yr year
dec decade
c century
final time = 42.minutes();

// '42 min'
final result1 = TimeFormat().format(time);

// '42 minutes'
final result2 = TimeFormat(pattern: '0.## U').format(time);

// '2,520,000 ms'
final result3 = TimeFormat(pattern: '###,##0.## u:ms').format(time);

See also:

Inheritance

Constructors

TimeFormat({String pattern = '0.## ${UnitOfMeasurementFormat.valueUnitSymbolFormatSpecifier}', Set<TimeUnit> permissibleValueUnits = TimeUnits.common, String? locale})

Properties

hashCode → int
The hash code for this object.
no setterinherited
locale → String?
The locale to use when formatting values.
finalinherited
pattern → String
The pattern that indicates the desired output when formatting input values.
finalinherited
permissibleRateUnits → Set<RateUnit>
finalinherited
permissibleValueUnits → Set<TimeUnit>
finalinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

format(Time input) → String
Formats input according to the pattern and locale of this format.
inherited
getLargestUnit(Time input) → TimeUnit
Determines the largest denomination of unit in input that has a value of at least 1.
override
getPatternSpecifierFor(TimeUnit valueUnit) → String
Gets the pattern specifier for the given value unit.
inherited
getPermissibleRateUnits() → Set<RateUnit>
Gets a set of permissible RateUnit values.
inherited
getPermissibleValueUnits() → Set<TimeUnit>
Gets a set of permissible TUnit values.
inherited
getUnitName(TimeUnit unit, String locale) → String
Gets the a unit name in the given locale.
inherited
getUnitQuantity(Time input, TimeUnit unit) → Decimal
Determines how many units of unit the input contains, including any fractional portion.
override
getUnitSymbol(TimeUnit unit, String locale) → String
Gets the a unit symbol in the given locale.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
scaleToRateUnit(Time input, RateUnit rateUnit) → Time
Scales input, which is assumed to be a rated unit of measurement, so that its rate is rateUnit.
override
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited