DistanceFormatter

class DistanceFormatter(context: Context, metricFormattingRanges: List<DistanceFormattingRange> = DEFAULT_METRIC_RANGES, usFormattingRanges: List<DistanceFormattingRange> = DEFAULT_US_UK_RANGES, ukFormattingRanges: List<DistanceFormattingRange> = DEFAULT_US_UK_RANGES)

Formatter to convert a Distance object to a FormattedDistance.

Important: This is a Public Preview API. It may be changed or removed at any time.

Parameters

context

Context used to retrieve a unit abbreviation string.

metricFormattingRanges

DistanceFormattingRange used for conversion to UnitSystem.METRIC or if the current locale is not set to Locale.US or Locale.UK.

usFormattingRanges

DistanceFormattingRange used for conversion to UnitSystem.US or if the current locale is set to Locale.US.

ukFormattingRanges

DistanceFormattingRange used for conversion to UnitSystem.UK or if the current locale is set to Locale.UK.

Constructors

Link copied to clipboard
fun DistanceFormatter(context: Context, metricFormattingRanges: List<DistanceFormattingRange> = DEFAULT_METRIC_RANGES, usFormattingRanges: List<DistanceFormattingRange> = DEFAULT_US_UK_RANGES, ukFormattingRanges: List<DistanceFormattingRange> = DEFAULT_US_UK_RANGES)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun format(distance: Distance, units: UnitSystem = UnitSystem.AUTO): FormattedDistance

Formats provided distance using metricFormattingRanges, usFormattingRanges and ukFormattingRanges.