The i18n Cookbook - recipies for a global society

  • java cookbook
  • about the author
Home

Java Cookbook

  • Java Internationalization Cookbook

parse

Format and parse a currency

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:

  • currency
  • format
  • numberformat
  • parse
  • Add new comment
  • Read more

Format and parse an integer

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:

  • numberformat
  • number format
  • parse
  • Add new comment
  • Read more

Parse a spelled-out number

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);

  • number format
  • parse
  • rulebasednumberformat
  • spellout
  • Add new comment
  • Read more

Parse a formatted date string

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.

 

  • date
  • Java
  • parse
  • Add new comment
  • Read more

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

Google
Custom Search
Syndicate content

Search

Tags in Tags

calendar date icu4j Java Locale number format numberformat parse spellout timezone transliteration transliterator
more tags

User login

  • Create new account
  • Request new password
  • java cookbook
  • about the author