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
🌐
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 › 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 }
🌐
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 › 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.
🌐
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.
🌐
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

Find elsewhere
🌐
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
🌐
GitHub
github.com › ibrahimsn98 › PhoneNumberKit
GitHub - ibrahimsn98/PhoneNumberKit: Android Kotlin library to parse and format international phone numbers. Country code picker. · GitHub
val formattedNumber = phoneNumberKit.formatPhoneNumber( number = "1266120000", defaultRegion = "us" )
Starred by 172 users
Forked by 41 users
Languages   Kotlin
🌐
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?
🌐
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.