Added in API level 30

CurrencyPrecision


abstract class CurrencyPrecision : Precision
kotlin.Any
   ↳ android.icu.number.Precision
   ↳ android.icu.number.CurrencyPrecision

A class that defines a rounding strategy parameterized by a currency to be used when formatting numbers in NumberFormatter.

To create a CurrencyPrecision, use one of the factory methods on Precision.

Summary

Public methods
open Precision!
withCurrency(currency: Currency!)

Associates a currency with this rounding strategy.

Inherited functions

Public methods

withCurrency

Added in API level 30
open fun withCurrency(currency: Currency!): Precision!

Associates a currency with this rounding strategy.

Calling this method is not required, because the currency specified in unit() or via a CurrencyAmount passed into format(Measure) is automatically applied to currency rounding strategies. However, this method enables you to override that automatic association.

This method also enables numbers to be formatted using currency rounding rules without explicitly using a currency format.

Parameters
currency Currency!: The currency to associate with this rounding strategy.
Return
Precision! A Precision for chaining or passing to the NumberFormatter rounding() setter.
Exceptions
java.lang.IllegalArgumentException for null Currency