This is the format you need:

val dec = DecimalFormat("#,###.##")

will print:

5.384,45

if you need always exactly 2 digits after the decimal point:

val dec = DecimalFormat("#,###.00") 
Answer from forpas on Stack Overflow
Discussions

DecimalFormat and NumberFormat libs for Kotlin Multiplatform ?
If you really want to go down this route it's likely you'll have to roll your own https://youtrack.jetbrains.com/issue/KT-21644/Add-utility-function-for-formatting-of-decimal-numbers-to-Kotlin-common-library Seems like a good opportunity for an open source project! :) However, Imo best practice would be to keep this type of device specific display formatting out of shared business logic and implement it in the platform specific code where you have access to things like Locale to inform how you format the numbers. More on reddit.com
🌐 r/Kotlin
1
12
April 14, 2023
java - Kotlin. How to format decimal number with zero at the end? - Stack Overflow
I need to format the number. I need the following result: 3434 -> 3 434 3434.34 -> 3 434.34 3434.3 -> 3 434.30 Here is my code: val formatter = DecimalFormat("#,###,##0.##")... More on stackoverflow.com
🌐 stackoverflow.com
Format a double to fixed decimal length - Support - Kotlin Discussions
Hi I want to round a Double (12345.12345) to a String with a fixed length after the ‘.’ Example: 12345.123 And: if it is 12345.1 It still should give me 12345.100 How can I do this in kotlin? More on discuss.kotlinlang.org
🌐 discuss.kotlinlang.org
1
November 28, 2020
Print floats with certain amount of decimal numbers - Support - Kotlin Discussions
Hello, I am trying to print a float with two decimal symbols. How to do that? More on discuss.kotlinlang.org
🌐 discuss.kotlinlang.org
2
June 20, 2016
🌐
Lets-plot
lets-plot.org › kotlin › formats.html
Formatting | Lets-Plot for Kotlin
March 20, 2026 - The list of supported directives to format date/time values: %a - weekday as an abbreviated name (Sun, Mon, …, Sat); %A - weekday as a full name (Sunday, Monday, …, Saturday) %b - month as an abbreviated name (Jan, Feb, …, Dec); %B - month as a full name (January, February, …, December); %d - day of the month as a zero-padded decimal number (01, 02, …, 31);
🌐
Android Developers
developer.android.com › api reference › numberformat
NumberFormat | API reference | Android Developers
Skip to main content · English · Deutsch · Español – América Latina · Français · Indonesia · Polski · Português – Brasil · Tiếng Việt · 中文 – 简体
🌐
Kotlin
kotlinlang.org › api › latest › jvm › stdlib › kotlin.text › format.html
format - Kotlin Programming Language
August 9, 2023 - See java.util.Formatter class documentation for the syntax of format specifiers for the format string. import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart // format with German conventions val withGermanThousandsSeparator = "%,d".format(Locale.GERMANY, 12345) println(withGermanThousandsSeparator) // 12.345 // 12.345 // format with US conventions val withUSThousandsSeparator = "%,d".format(Locale.US, 12345) println(withUSThousandsSeparator) // 12,345 //sampleEnd }
🌐
Kotlin
kotlinlang.org › api › core › kotlin-stdlib › kotlin.text › format.html
format | Core API – Kotlin Programming Language
See java.util.Formatter class documentation for the syntax of format specifiers for the format string. ... import kotlin.test.* import java.util.* import java.util.regex.* fun main() { //sampleStart // format with German conventions val withGermanThousandsSeparator = "%,d".format(Locale.GERMANY, 12345) println(withGermanThousandsSeparator) // 12.345 // 12.345 // format with US conventions val withUSThousandsSeparator = "%,d".format(Locale.US, 12345) println(withUSThousandsSeparator) // 12,345 //sampleEnd }
🌐
Baeldung
baeldung.com › home › kotlin › kotlin numbers › format number with thousand separator in kotlin
Format Number With Thousand Separator in Kotlin | Baeldung on Kotlin
February 22, 2025 - The “#,###” pattern will format our number to a thousand-separated String, but with a comma separator.
🌐
Kotlin
kotlinlang.org › api › latest › jvm › stdlib › kotlin.text › -hex-format › number.html
number | Core API – Kotlin Programming Language
kotlin-stdlib / kotlin.text / HexFormat / number · Common · JVM · JS · Native · 1.0 · val number: NumberHexFormat (source) Specifies the hexadecimal format used for formatting and parsing numeric values.
Find elsewhere
🌐
Reddit
reddit.com › r/kotlin › decimalformat and numberformat libs for kotlin multiplatform ?
r/Kotlin on Reddit: DecimalFormat and NumberFormat libs for Kotlin Multiplatform ?
April 14, 2023 -

I'm working on a multiplatform library with Kotlin

We need to display numbers with either "comma decimal " and "dot decimal" formats based on the locale

For example

  1. 1,00,000.50 for India , 1.00.00,50 for Europe

For this purpose I used Java's number format and Decimal format classes

DecimalFormat decim = new DecimalFormat("#,###.##"); tv.setText(decim.format(someFloat));

OR

NumberFormat.getInstance().format(my number) 

Both are good, but they are JAVA libraries won't work in KMM code

So, my question, is there any DecimalFormat and NumberFormat alternate libraires available for Kotlin Multiplatform ?

I don't like to use Expect / Actual implementation but a native ones

🌐
Kotlin
kotlinlang.org › api › core › kotlin-stdlib › kotlin.text › -hex-format › -number-hex-format
NumberHexFormat | Core API – Kotlin Programming Language
For example, use val format = HexFormat { number.prefix = "0x" } to set the prefix. The number property is of type NumberHexFormat.Builder, whose options are configurable and correspond to the options of this class. ... import kotlin.test.* fun main() { //sampleStart val numberHexFormat = HexFormat { upperCase = true number { removeLeadingZeros = true minLength = 4 prefix = "0x" } } println(0x3a.toHexString(numberHexFormat)) // 0x003A println("0x003A".hexToInt(numberHexFormat)) // 58 // Parsing is case-insensitive println("0X003a".hexToInt(numberHexFormat)) // 58 //sampleEnd }
🌐
JetBrains
youtrack.jetbrains.com › issue › KT-21644 › Add-utility-function-for-formatting-of-decimal-numbers-to-Kotlin-common-library
Add utility function for formatting of decimal numbers to ...
{{ (>_<) }} This version of your browser is not supported. Try upgrading to the latest stable version. Something went seriously wrong
🌐
JetBrains
youtrack.jetbrains.com › issue › KT-21644
Add utility function for formatting of decimal numbers to Kotlin ...
{{ (>_<) }} This version of your browser is not supported. Try upgrading to the latest stable version. Something went seriously wrong
🌐
Kotlin
kotlinlang.org › docs › numbers.html
Numbers | Kotlin Documentation
March 2, 2020 - For real numbers, Kotlin provides floating-point types Float and Double that adhere to the IEEE 754 standard.
🌐
Programiz
programiz.com › kotlin-programming › examples › round-number-decimal
Kotlin Program to Round a Number to n Decimal Places
We declare the format using the # patterns #.###. This means, we want num upto 3 decimal places. We also set the rounding mode to Ceiling, this causes the last given place to be rounded to its next number.
🌐
GitHub
gist.github.com › nprk › 999faa0d324e54bd59bae7def933b495
Kotlin: compact decimal format (1200 -> 1.2k) · GitHub
Kotlin: compact decimal format (1200 -> 1.2k). GitHub Gist: instantly share code, notes, and snippets.
🌐
Kotlin Discussions
discuss.kotlinlang.org › support
Format a double to fixed decimal length - Support - Kotlin Discussions
November 28, 2020 - Hi I want to round a Double (12345.12345) to a String with a fixed length after the ‘.’ Example: 12345.123 And: if it is 12345.1 It still should give me 12345.100 How can I do this in kotlin?
🌐
Kotlin Discussions
discuss.kotlinlang.org › support
Print floats with certain amount of decimal numbers - Support - Kotlin Discussions
June 20, 2016 - Hello, I am trying to print a float with two decimal symbols. How to do that?
🌐
Sling Academy
slingacademy.com › article › formatting-numbers-for-display-in-kotlin-currency-percentages
Formatting Numbers for Display in Kotlin (Currency, Percentages) - Sling Academy
To format numbers into currency, Kotlin can leverage the DecimalFormat class from Java, which allows custom formatting options.