- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
Hi All,
As you all know, that number format changes based on language.
E.g. In Spanish/French comma (,) replace with dot(.) and dot(.) replaced with comma (,)
Let's see how we can do this with our OOB Class
GlideNumberFormatter API - Scoped, Global
The GlideNumberFormatter API includes methods that return numbers formatted according to the language of the current user.
This API is available in scoped and global apps and is called with the sn_i18n namespace.
When formatted by language or locale, users can view numbers as expected. For example, if the locale is fr (French), a value provided as 100.00 returns as 100,00 instead.
GlideNumberFormatter – format(Number number)
Provides a string representation of a number formatted according to the language setting of the current user.
| number | Number | Number of any size. |
| String | Number formatted according to the language setting of the current user. |
Example
The following example shows the output for a user with language set to Spanish.
gs.info("Number is: " + sn_i18n.NumberFormatter.format(123456.789));
gs.info("Number is: " + sn_i18n.NumberFormatter.format(-123456.789));Output:
Number is: 123.456,789 Number is: -123.456,789
Hope this helps you!!
I hope this article helpful. Please mark it as helpful and bookmark if you like it.
Regards,
Shamma Negi
- 594 Views
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
