Is this content useful for you? Support this site by donating any amount....(takes you to Paypal website)
Other Amount

Categories

Number to Words Output on Windows console
Java, Programming, Scripting

Number to Words in Java

Read Time:1 Minute, 4 Second

Last Updated on April 19, 2024 by Hammad Rauf

This is related to an old post. This time I have translated it from C/C++ to Java and modified it a little bit. Now it takes as input additional parameters of currency-Note, currency-Coin and coin-Places. It is open sourced under Apache Software license 2.0. Source code can be found on Github.

Number-to-Words-in-Java is a program that takes as input a number and outputs the same number in English words form. It will be useful in situations like Bank Cheque printing. I was able to embed it in a Jaspersoft Studio Report, as shown in screen shots below.

Parameters Explained

Parameters for NumberToWords (in Java)
1NameNumber
Data-TypeBigDecimal
DescriptionThe Double or Float numeric value which needs to be converted into words.
2NamecurrencyNote
Data-TypeString
DescriptionThe currency name that will appear in the output for the whole number part.
3NamecurrencyCoin
Data-TypeString
DescriptionThe currency coin name that will appear in the output for the fractional number part.
4NamecoinPlaces
Data-TypeInteger
DescriptionNumber of digits in the coin output. For example for Dollar and Cents it should be 2. For some currency like Bahraini Dinar and Fills it will be 3.

In use inside – Jaspersoft Studio Report

Number To Words (Java) In use inside Jaspersoft Studio - 01 - Report Preview
Number To Words (Java) In use inside Jaspersoft Studio – 01 – Report Preview

 

Number To Words (Java) In use inside Jaspersoft Studio -02- Code View
Number To Words (Java) In use inside Jaspersoft Studio -02- Code View

References

  1. The old post for C/C++ Function, https://andromedabay.ddns.net/number-to-words-recursive/, Date Accessed: March 28, 2024
  2. The old C/C++ Function, http://codepad.org/C29M1wUQ, Date Accessed: March 28, 2024
  3. Github repository for this (Java) Method, https://github.com/hexword-ca/NumberToWords, Date Accessed: March 28, 2024

 

Leave a Reply

Your email address will not be published. Required fields are marked *