function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Prem ChauhanPrem Chauhan 

how to convert decimal numbers like (1234.12) to words in salesforce??

how to convert decimal numbers like (1234.12) to words in salesforce??

I need an output like this...

1234.12 = one thousand two hundred thirty-four. twelve paise (INR)
 I am getting this much of output 'one thousand two hundred thirty-four' but not getting how to append that "twelve paise" after the decimal point. 

Thanks in Advance...  
Best Answer chosen by Prem Chauhan
YogeshMoreYogeshMore
Hi Prem,
 
If you are getting required out put before dot, then following solution helps you to achieve your requirement by splitting the value.
For example, you have value like 1234.12.
Decimal Num = 1234.12; // This is your Number
String strVal = String.ValueOf(Num); // Convert Number to string
List<String> lstNum = strVal.Split(‘.’); // Split number by dot, List size will be two.
String NumberToString = ‘’;
If(lstNum.size()>0){`
            String NumberToString1 = CallYourNumberToStrimgMethod(lstNum[0]);// Get Number to String of before decimal place.
                String NumberToString2 = CallYourNumberToStrimgMethod(lstNum[1]);// Get Number to String of after decimal place.
NumberToString = NumberToString1 + NumberToString2; // here you will get exact out put.
 }

Please mark this answer as SOLVED and BEST ANSWER if it helps you.

Regards,
Yogesh More

Salesforce consultant || Salesforce Developer
more.yogesh422@gmail.com || Skype:-yogesh.more44​

All Answers

YogeshMoreYogeshMore
Hi Prem,
 
If you are getting required out put before dot, then following solution helps you to achieve your requirement by splitting the value.
For example, you have value like 1234.12.
Decimal Num = 1234.12; // This is your Number
String strVal = String.ValueOf(Num); // Convert Number to string
List<String> lstNum = strVal.Split(‘.’); // Split number by dot, List size will be two.
String NumberToString = ‘’;
If(lstNum.size()>0){`
            String NumberToString1 = CallYourNumberToStrimgMethod(lstNum[0]);// Get Number to String of before decimal place.
                String NumberToString2 = CallYourNumberToStrimgMethod(lstNum[1]);// Get Number to String of after decimal place.
NumberToString = NumberToString1 + NumberToString2; // here you will get exact out put.
 }

Please mark this answer as SOLVED and BEST ANSWER if it helps you.

Regards,
Yogesh More

Salesforce consultant || Salesforce Developer
more.yogesh422@gmail.com || Skype:-yogesh.more44​
This was selected as the best answer
Ram2026Ram2026
Hi Prem,

User also wants similar solution. Can you please share the code? Thanks.