The i18n Cookbook - recipies for a global society

  • java cookbook
  • about the author
Home

Java Cookbook

  • Java Internationalization Cookbook

numberformat

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 a percent

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:

  • numberformat
  • percent
  • Add new comment
  • Read more

Format and parse a decimal

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:

  • decimal
  • numberformat
  • 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

Numerical Systems

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

  • Java
  • numberformat
  • number formatting
  • Add new comment

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