Different countries have different number formats and considering this we can have different formats using Locale of java. Using locale can help in formatting
Locale locale = new Locale(“en”, “IN”); NumberFormat numberFormat = NumberFormat.getInstance(locale); |
using above format you can perform various tasks
- Format Number
numberFormat.format(10000000.99);
- Format Currency
NumberFormat currencyFormat = NumberFormat.getCurrencyInstance(locale); currencyFormat.format(10340.999);
- Format Percentage
NumberFormat percentageFormat = NumberFormat.getPercentInstance(locale); percentageFormat.format(10929.999);
- Control Number of Digits
numberFormat.setMinimumIntegerDigits(int digits) numberFormat.setMaximumIntegerDigits(int digits) numberFormat.setMinimumFractionDigits(int digits) numberFormat.setMaximumFractionDigits(int digits) |
About us and this blog
We are a digital marketing company with a focus on helping our customers achieve great results across several key areas.
Request a free quote
We offer professional SEO services that help websites increase their organic search score drastically in order to compete for the highest rankings even when it comes to highly competitive keywords.
Subscribe to our newsletter!
More from our blog
See all postsRecent Posts
- Chapter120:YieldKeyword 20/05/2024
- Chapter119:LockStatement 19/05/2024
- Chapter118:Makingavariablethreadsafe 18/05/2024