Manage regional formats
Text fields and related components, such as date and time pickers, automatically apply locale-specific formatting patterns. These include the formatting of numbers, dates, times, and currencies. The patterns are determined by the system's locale or a custom locale set within your application, ensuring consistent data display across platforms.
Locale formatting patterns
Formatting in Compose Multiplatform respects platform-specific locale conventions for:
Numeric separators. Thousands can get separated by a comma or a period:
1,234.56
inen-US
and1.234,56
inde-DE
.Date/Time patterns. The date of December 1 looks like
12/1/20
inen-US
, while the same date infr-CA
looks like2020-12-01
.Currency symbols and placement. The local currency symbol can be placed either before or after the digits:
$5,001
inen-US
and5.001,00 €
infr-FR
.
These regional formats work out of the box for both system locales and custom locale overrides defined in your app.
Formatting is currently implemented using the kotlinx-datetime
library on iOS and the JDK API on Android and desktop. Here is an example of managing localized date and currency values in the iOS source set:
Ensure consistent formatting
Although there is no common API for a unified multiplatform solution, the formatting behavior is still consistent in most cases. To ensure the formatting is correct for all supported regions:
Test edge cases such as large numbers, negative values, or zeroes.
Verify formatting for all supported locales on all target platforms.
What's next
Learn how to manage the application's resource environment like in-app theme and language.