Java Cookbook
parse
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 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:
Problem:
You want to convert a spelled out number to a Number.
Solution:
Parsing a formatted number in Java takes a new twist when the number is fully spelled out. This can be easily accomplished thanks to the ICU4J library from IBM.
To parse a spelled out number:
//Get a RuleBasedNumberFormat appropriate for French spellout
RuleBasedNumberFormat rbnf = new RuleBasedNumberFormat(ULocale.ENGLISH,RuleBasedNumberFormat.SPELLOUT);
Problem:
You want to parse a localized date string to a Java Date.
Solution:
As important as date formatting is, you have to be able to parse the formatted dates. Parsing a date is very similar to formatting the date. You just call the parse method on a DateFormat instance.
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