How to convert number to words in java

前端 未结 27 3214
遇见更好的自我
遇见更好的自我 2020-11-21 23:53

We currently have a crude mechanism to convert numbers to words (e.g. using a few static arrays) and based on the size of the number translating that into an english text. B

27条回答
  •  耶瑟儿~
    2020-11-22 00:42

    I've developed a Java component to convert given number into words. All you've to do is - just copy the whole class from Java program to convert numbers to words and paste it in your project.

    Just invoke it like below

    Words w = Words.getInstance(1234567);
    System.out.println(w.getNumberInWords());
    

    My program supports up to 10 million. If you want, you can still extend this. Just below the example output

    2345223 = Twenty Three Lakh Fourty Five Thousand Two Hundred Twenty Three
    9999999 = Ninety Nine Lakh Ninety Nine Thousand Nine Hundred Ninety Nine
    199 = One Hundred Ninety Nine
    10 = Ten
    

    Thanks

    Santhosh

提交回复
热议问题