Using currency subunits in Android

20 views Asked by At

I am using the currency for 6 countries in my Android application.

Using the below code, I am able to get the amounts in the right display type:

val currencyFormatter = NumberFormat.getCurrencyInstance(
            Locale(RegionInfo.REGION_LANGUAGE, RegionInfo.REGION_COUNTRY)
        )

val displayValue = currencyFormatter.format(amount) // e.g. amount = 2.3

This works well for all situations where the currency value is greater than 1 like UK(£2.3), US($2.3), ROI(€2.3)

I want to use the Currency class or the NumberFormat class to help me get subunit values for amount under 1.

Like: UK(75p), US(75c), ROI(75c) etc.

How can we achieve this to cater all currencies?

0

There are 0 answers