Format number as localized string with same number of decimals

1 Answer 49 Views
Localization
Lee
Top achievements
Rank 2
Bronze
Bronze
Bronze
Lee asked on 21 Apr 2023, 03:37 PM

I have a number that I need to display on the screen in the user's number format. The number can be of any length and have any number of decimals. I need the commas or periods to be displayed between the thousands and decimals as appropriate. For example:
123456789.12345 should display as 123,456,789.12345 in en-US

123456789.12345 should display as 123.456.789,12345 in de-DE

1234 should be 1,234 and 1.234 respectively. 

123.16 should be 123.16 and 123,16 respectively.

When I use kendo.toString(1234.165, "n") I get 1,234.17 which is not what I want. I want it to be 1,234.165

1 Answer, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 26 Apr 2023, 09:04 AM

Hello Lee,

You can use the "#" sign - it is a placeholder that replaces the pound sign with the corresponding digit if one is present.

In the Dojo linked here, you will find how numbers with different counts of decimals will appear in 'en-US' and 'de=DE' cultures.

I hope this helps.

Regards,
Neli
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Localization
Asked by
Lee
Top achievements
Rank 2
Bronze
Bronze
Bronze
Answers by
Neli
Telerik team
Share this question
or