# CurrencyPrecision

Added in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Methods](https://developer.android.com/reference/android/icu/number/CurrencyPrecision#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/icu/number/CurrencyPrecision#inhmethods)  

# CurrencyPrecision

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/icu/number/CurrencyPrecision "View this page in Kotlin")\|Java

`
public


abstract
class
CurrencyPrecision
`  
`


``

extends `[Precision](https://developer.android.com/reference/android/icu/number/Precision)`


``


`

|---|---|--------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [android.icu.number.Precision](https://developer.android.com/reference/android/icu/number/Precision) ||
|   | ↳ | android.icu.number.CurrencyPrecision |

<br />

*** ** * ** ***

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.  
**See also:**

- [NumberFormatter](https://developer.android.com/reference/android/icu/number/NumberFormatter)

## Summary

|                                                                                                                                                                              ### Public methods                                                                                                                                                                               ||
|--------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[Precision](https://developer.android.com/reference/android/icu/number/Precision) | ` `[withCurrency](https://developer.android.com/reference/android/icu/number/CurrencyPrecision#withCurrency(android.icu.util.Currency))`(`[Currency](https://developer.android.com/reference/android/icu/util/Currency)` currency) ` Associates a currency with this rounding strategy. |

| ### Inherited methods |
|-----------------------|---|
| From class` `[android.icu.number.Precision](https://developer.android.com/reference/android/icu/number/Precision)` ` |-------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` static `[CurrencyPrecision](https://developer.android.com/reference/android/icu/number/CurrencyPrecision) | ` `[currency](https://developer.android.com/reference/android/icu/number/Precision#currency(android.icu.util.Currency.CurrencyUsage))`(`[Currency.CurrencyUsage](https://developer.android.com/reference/android/icu/util/Currency.CurrencyUsage)` currencyUsage) ` Show numbers rounded and padded according to the rules for the currency unit.                                                                 | | ` static `[FractionPrecision](https://developer.android.com/reference/android/icu/number/FractionPrecision) | ` `[fixedFraction](https://developer.android.com/reference/android/icu/number/Precision#fixedFraction(int))`(int minMaxFractionPlaces) ` Show numbers rounded if necessary to a certain number of fraction places (numerals after the decimal separator).                                                                                                                                                         | | ` static `[Precision](https://developer.android.com/reference/android/icu/number/Precision)                 | ` `[fixedSignificantDigits](https://developer.android.com/reference/android/icu/number/Precision#fixedSignificantDigits(int))`(int minMaxSignificantDigits) ` Show numbers rounded if necessary to a certain number of significant digits or significant figures.                                                                                                                                                 | | ` static `[Precision](https://developer.android.com/reference/android/icu/number/Precision)                 | ` `[increment](https://developer.android.com/reference/android/icu/number/Precision#increment(java.math.BigDecimal))`(`[BigDecimal](https://developer.android.com/reference/java/math/BigDecimal)` roundingIncrement) ` Show numbers rounded if necessary to the closest multiple of a certain rounding increment.                                                                                                | | ` static `[FractionPrecision](https://developer.android.com/reference/android/icu/number/FractionPrecision) | ` `[integer](https://developer.android.com/reference/android/icu/number/Precision#integer())`() ` Show numbers rounded if necessary to the nearest integer.                                                                                                                                                                                                                                                       | | ` static `[FractionPrecision](https://developer.android.com/reference/android/icu/number/FractionPrecision) | ` `[maxFraction](https://developer.android.com/reference/android/icu/number/Precision#maxFraction(int))`(int maxFractionPlaces) ` Show numbers rounded if necessary to a certain number of fraction places (numerals after the decimal separator).                                                                                                                                                                | | ` static `[Precision](https://developer.android.com/reference/android/icu/number/Precision)                 | ` `[maxSignificantDigits](https://developer.android.com/reference/android/icu/number/Precision#maxSignificantDigits(int))`(int maxSignificantDigits) ` Show numbers rounded if necessary to a certain number of significant digits/figures.                                                                                                                                                                       | | ` static `[FractionPrecision](https://developer.android.com/reference/android/icu/number/FractionPrecision) | ` `[minFraction](https://developer.android.com/reference/android/icu/number/Precision#minFraction(int))`(int minFractionPlaces) ` Always show at least a certain number of fraction places after the decimal separator, padding with zeros if necessary.                                                                                                                                                          | | ` static `[FractionPrecision](https://developer.android.com/reference/android/icu/number/FractionPrecision) | ` `[minMaxFraction](https://developer.android.com/reference/android/icu/number/Precision#minMaxFraction(int,%20int))`(int minFractionPlaces, int maxFractionPlaces) ` Show numbers rounded if necessary to a certain number of fraction places (numerals after the decimal separator); in addition, always show at least a certain number of places after the decimal separator, padding with zeros if necessary. | | ` static `[Precision](https://developer.android.com/reference/android/icu/number/Precision)                 | ` `[minMaxSignificantDigits](https://developer.android.com/reference/android/icu/number/Precision#minMaxSignificantDigits(int,%20int))`(int minSignificantDigits, int maxSignificantDigits) ` Show numbers rounded if necessary to a certain number of significant digits/figures; in addition, always show at least a certain number of significant digits, padding with zeros if necessary.                     | | ` static `[Precision](https://developer.android.com/reference/android/icu/number/Precision)                 | ` `[minSignificantDigits](https://developer.android.com/reference/android/icu/number/Precision#minSignificantDigits(int))`(int minSignificantDigits) ` Always show at least a certain number of significant digits/figures, padding with zeros if necessary.                                                                                                                                                      | | ` `[Precision](https://developer.android.com/reference/android/icu/number/Precision)                        | ` `[trailingZeroDisplay](https://developer.android.com/reference/android/icu/number/Precision#trailingZeroDisplay(android.icu.number.NumberFormatter.TrailingZeroDisplay))`(`[NumberFormatter.TrailingZeroDisplay](https://developer.android.com/reference/android/icu/number/NumberFormatter.TrailingZeroDisplay)` trailingZeroDisplay) ` Configure how trailing zeros are displayed on numbers.                 | | ` static `[Precision](https://developer.android.com/reference/android/icu/number/Precision)                 | ` `[unlimited](https://developer.android.com/reference/android/icu/number/Precision#unlimited())`() ` Show all available digits to full precision.                                                                                                                                                                                                                                                                | ||
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Public methods

### withCurrency

Added in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Precision withCurrency (Currency currency)
```

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.

<br />

|                                      Parameters                                       ||
|------------|---------------------------------------------------------------------------|
| `currency` | `Currency`: The currency to associate with this rounding strategy. <br /> |

|                                                                                 Returns                                                                                 ||
|-----------------------------------------------------------------------------------|--------------------------------------------------------------------------------------|
| [Precision](https://developer.android.com/reference/android/icu/number/Precision) | A Precision for chaining or passing to the NumberFormatter rounding() setter. <br /> |

|                                                          Throws                                                           ||
|--------------------------------------------------------------------------------------------------------|-------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | for null Currency |

**See also:**

- [NumberFormatter](https://developer.android.com/reference/android/icu/number/NumberFormatter)