Skip to main content
May 18, 2009
Question

Convert a number to it's text equivalent

  • May 18, 2009
  • 2 replies
  • 594 views

Hello all,

I am currently working on a project in which I need to take a number that will be in the form of a currency, and convert it into it's text representation.

EX: 15.00

Becomes: Fifteen dollars 00/100

Or

EX: 66.00

Becomes: Sixty-six 00/100

If someone has a function that can do this, or can outline a good method on how to do so, please let me know. For some reason the logic on this has me a little stumped. Thanks.

    This topic has been closed for replies.

    2 replies

    Inspiring
    May 19, 2009

    might be overkill but icu4j's rule based formatting will handle this in several

    locales plus duration ("2 days from now") & ordinal ("1st", "2nd") formatting.

    http://www.icu-project.org/download/4.0.html#ICU4J

    specifically:

    http://www.icu-project.org/apiref/icu4j/com/ibm/icu/text/RuleBasedNumberFormat.html

    Inspiring
    May 18, 2009

    Check cflib.org.  I cannot recall the name of the function, but I am pretty sure they have one that does this.