The i18n Cookbook - recipies for a global society

  • java cookbook
  • about the author
Home

Java Cookbook

  • Java Internationalization Cookbook

format

Format a time amount

Problem:

You want to format a time amount like "5 days" for a locale.

Solution:

TimeUnitFormat from icu4j provides some excellent formatting options for time units.  To use you specify a TimeUnitAmount which contains an amount and a unit.  Then specify a locale on the TimeUnitFormat.

To format 1 day in French:

  • date formatting
  • format
  • Add new comment
  • Read more

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

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