Moving an Android app to Kotlin Multiplatform looks easy when it comes to showing numbers: you only need a few decimals and a thousands separator. Then you find that the two Java tools you relied on are not available in common code, and that they never rounded the same way in the first place. This is what I learned while moving the formatting of an existing app, and how I rebuilt it so that Android and iOS print exactly the old text.
What disappears in common code
Common Kotlin code is compiled for every target, so it cannot call Java classes. That removes java.text.NumberFormat, which my app used for money amounts with grouping separators, and String.format, which it used for everything with a fixed number of decimals. Each platform has its own formatting classes, and you could call them through a small interface with one implementation for Android and one for iOS.
I did not take that route.…