Java Cookbook
numberformat
Problem:
You want to format and parse localized currency values.
Solution:
Currency formatting at its most basic is straight forward in Java programming. Simply retrieve a currency instance of the NumberFormat class and format your number.
To format a currency for Japanese for Japan:
Problem:
You want to format and parse percent values.
Solution:
The Java NumberFormat class makes it easy to create a localized format for a percent value. Simply pass the locale when retrieving your instance. The format will see 1 as 100% and .1 as 10%.
To format and parse a percent value for Brazillian Portuguese:
Problem:
You want to format and parse decimal values.
Solution:
Localized formatting of decimal values is easy in Java. It can be accomplished by passing the number into the getInstance method on the NumberFormat class. Then simply call format and parse.
To format and parse a decimal value for Arabic:
Problem:
You want to format and parse integer values.
Solution:
The Java NumberFormat class makes formatting and parsing a number is localized manner easy and efficient. Simple specify the locale when retrieving the NumberFormat instance.
To format and parse a number in Hindi:
Formatting numbers is straight forward in Java. Many developers overlook this aspect of localization. Numeric systems vary around the world, and even more importantly the delimiters and separators vary. ICU4J provides even more capabilities
If you are testing any of these recipes in Eclipse and the characters are not displaying correctly in your console visit http://i18ncookbook.com/eclipse_settings.
This site is ad supported. I hope you find something among our sponsors worth clicking. ;)
i18n search