
Facilitates currency management by providing classes for handling ISO 4217 currency codes and details, including code validation and retrieval of internationalized currency information.
Kotlin multiplatform currency library.
This is most useful in combination with fluid-i18n for retrieving internationalized information about a currency.
build.gradle.kts:
dependencies {
implementation("io.fluidsonic.currency:fluid-currency:0.13.0")
}println(Currency.fromCode("EUR")) // EURA class with information about a specific currency defined by ISO 4217.
val currency = Currency.forCode("EUR") // throws if code is invalid (not defined by ISO 4217) or has an invalid format (not three latin letters)
println(currency.code) // EUR
println(currency.defaultFractionDigits) // 2
println(currency.numericCode) // 978val currency = Currency.forCodeOrNull("ABC123") // null if code is invalid (not defined by ISO 4217) or has an invalid format (not three latin letters)
println(currency) // nullAn inline class for ISO 4217 3-letter currency codes (e.g. EUR or USD).
val code = CurrencyCode.parse("EUR") // throws if code has invalid format (not three latin letters)
println(code.toString()) // EUR
println(code.isValid()) // true - 'EUR' is defined by ISO 4217val code = CurrencyCode.parse("abc") // throws if code has invalid format (not three latin letters)
println(code.toString()) // ABC
println(code.isValid()) // false - 'ABC' is not defined by ISO 4217val code = CurrencyCode.parseOrNull("ABC123") // null if code has invalid format (not three latin letters)
println(code) // nullApache 2.0
Kotlin multiplatform currency library.
This is most useful in combination with fluid-i18n for retrieving internationalized information about a currency.
build.gradle.kts:
dependencies {
implementation("io.fluidsonic.currency:fluid-currency:0.13.0")
}println(Currency.fromCode("EUR")) // EURA class with information about a specific currency defined by ISO 4217.
val currency = Currency.forCode("EUR") // throws if code is invalid (not defined by ISO 4217) or has an invalid format (not three latin letters)
println(currency.code) // EUR
println(currency.defaultFractionDigits) // 2
println(currency.numericCode) // 978val currency = Currency.forCodeOrNull("ABC123") // null if code is invalid (not defined by ISO 4217) or has an invalid format (not three latin letters)
println(currency) // nullAn inline class for ISO 4217 3-letter currency codes (e.g. EUR or USD).
val code = CurrencyCode.parse("EUR") // throws if code has invalid format (not three latin letters)
println(code.toString()) // EUR
println(code.isValid()) // true - 'EUR' is defined by ISO 4217val code = CurrencyCode.parse("abc") // throws if code has invalid format (not three latin letters)
println(code.toString()) // ABC
println(code.isValid()) // false - 'ABC' is not defined by ISO 4217val code = CurrencyCode.parseOrNull("ABC123") // null if code has invalid format (not three latin letters)
println(code) // nullApache 2.0