Introducing number and currency formaters (and more) for KMP in pale-blue-kmp-core
At Pale Blue, we’re big believers in Kotlin Multiplatform (KMP) and continue to push its boundaries with tools and libraries we use daily across our products. Today, we’re happy to announce a new set of features added to pale-blue-kmp-core
, our open-source utility library for Kotlin Multiplatform developers.
In this release, we’re addressing a couple of pain points we’ve repeatedly encountered in real-world app development: formatting numbers and currencies in a locale-aware way, and preserving type-safe result handling across platforms.
Native currency and number formatters
Formatting currency and numbers correctly across locales has always been a tricky task in Kotlin Multiplatform. There’s currently no built-in solution that works out-of-the-box across iOS and Android while leveraging native platform capabilities. That’s why we’ve added CurrencyFormatter
and NumberFormatter
to pale-blue-kmp-core
.
Both formatters are backed by native implementations, ensuring that the output is locale-aware, consistent, and reliable.
CurrencyFormatter
val currencyFormatter = CurrencyFormatter()
val formattedAmount = currencyFormatter.format(
amount = 1234.56,
currencyCode = "USD",
withCurrencySymbol = true,
minimumFractionDigits = 2,
maximumFractionDigits = 2
)
// Output: "$1,234.56"
Works as expected with all major currency codes and supports optional inclusion of the currency symbol.
NumberFormatter
val numberFormatter = NumberFormatter()
val formattedNumber = numberFormatter.format(
number = 1234567.89,
localeCode = "en-US"
)
// Output: "1,234,567.89"
Supports locale codes in the format "en-US"
, making your app feel more local no matter the region.
These formatters fill a much-needed gap in the KMP ecosystem and are ideal for any app that deals with prices, financial data, or user-inputted numbers.
KmmResult: A type-safe result wrapper
We’ve also introduced KmmResult
, a Kotlin Multiplatform-friendly wrapper for modeling success and failure cases with full type information preserved across platforms.
It’s inspired by Kotlin’s built-in Result
, but works safely in shared code and integrates cleanly with iOS and Android error handling idioms.
fun loadUserData(): KmmResult<User> {
return try {
KmmResult.success(fetchUser())
} catch (e: Exception) {
KmmResult.failure(e)
}
}
On iOS, you still get type-safe results — no type erasure, no hacks, just clean shared logic.
The new version of the library that contains these features is already available on GitHub. These additions are already powering real apps in production, and we hope they’ll help the broader KMP community ship cleaner, safer, and more polished apps. Feel free to open issues, or just star the repo to follow along.
Happy coding!