public abstract class MeasureFormatter extends Object
| 构造器 | 说明 |
|---|---|
MeasureFormatter() |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
abstract String |
format(MeasureOptions.Unit unit,
double value,
MeasureOptions.FormatStyle formatStyle) |
Formats weights and measures based on the specified unit, value, and formatting style.
|
abstract String |
format(MeasureOptions.Unit fromUnit,
double value,
MeasureOptions.Unit toUnit,
MeasureOptions.FormatStyle formatStyle) |
Converts the source unit to the target unit and formats the target unit according to the
specified formatting style.
|
abstract String |
format(MeasureOptions.Unit unit,
double value,
MeasureOptions.Usage usage,
MeasureOptions.FormatStyle formatStyle,
MeasureOptions.Style style) |
Selects a preferred unit in the specified application scenario based on the locale of the
MeasureFormatter object and formats the preferred unit according to the specified
formatting style. |
static MeasureFormatter |
getInstance() |
Creates a
MeasureFormatter instance with the current locale. |
static MeasureFormatter |
getInstance(Locale locale) |
Creates a
MeasureFormatter instance with a specified locale. |
abstract void |
setFractionPrecision(int value) |
Sets the precision of the fraction in the number displayed in the formatted string.
|
public static MeasureFormatter getInstance()
MeasureFormatter instance with the current locale.MeasureFormatter instance.public static MeasureFormatter getInstance(Locale locale)
MeasureFormatter instance with a specified locale.locale - Indicates the specified locale.MeasureFormatter instance.public abstract void setFractionPrecision(int value)
value - Indicates the precision of the fraction.public abstract String format(MeasureOptions.Unit unit, double value, MeasureOptions.FormatStyle formatStyle)
unit - Indicates the specified unit.value - Indicates the value of the unit.formatStyle - Indicates the formatting style.public abstract String format(MeasureOptions.Unit unit, double value, MeasureOptions.Usage usage, MeasureOptions.FormatStyle formatStyle, MeasureOptions.Style style) throws NotSupportConvertException
MeasureFormatter object and formats the preferred unit according to the specified
formatting style.
If there are multiple preferred units, the style parameter determines whether to
automatically select a proper one. The value of the input unit is then converted to that of
the preferred unit.
unit - Indicates the input unit.value - Indicates the value of the unit.usage - Indicates the application scenario of the unit.formatStyle - Indicates the formatting style.style - Specifies whether to automatically select a proper unit.NotSupportConvertException - Throws this exception if any input parameter is invalid.public abstract String format(MeasureOptions.Unit fromUnit, double value, MeasureOptions.Unit toUnit, MeasureOptions.FormatStyle formatStyle) throws NotSupportConvertException
fromUnit - Indicates the source unit.value - Indicates the value of the source unit.toUnit - Indicates the target unit.formatStyle - Indicates the formatting style.NotSupportConvertException - Throws this exception if the source unit cannot
be converted to the target unit.