The i18n Cookbook - recipies for a global society

  • java cookbook
  • about the author
Home

Java Cookbook

  • Java Internationalization Cookbook

spellout

Spell out the numeric value in a concatenated string

 Problem:

You want to spell out a dynamic numeric value being combined with a static resource.

Solution:

Java MessageFormat provides a number of options for formatting the values passed in.  ICU4J provides even more options.

One of the more interesting formatting options is the spellout format.  Spell out will actually write out a numeric value, such as thirty-five vs. 35.

ICU4J's MessageFormat is used similar to the code Java class.

To format a pattern using a spellout pattern:

  • icu4j
  • messageformat
  • spellout
  • 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

Spell out a numeric value

Problem:

You want to spell out a localized number like "thirty-six."

Solution:

ICU4J provides some number formatting capabilities that core Java does not.  One of those features is the ability to spell out a numeric value. 

 

  • icu4j
  • number format
  • spellout
  • 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