on 01-02-2009 2:54 PM
Hi,
Can any body help in writing an UDF, for the below requirement.
If my input comes as 5.000 I want the output as 0005, I want to truncate the zeros after decimal and to add zeros before the value to make the total length to 4. If the input is 25.00 then i want output as 0025.
Thanks in advance.
Regards,
Jayaram.G
Hi,
You DO NOT NEED UDF for this. As this feature is available with Standard Arithmatic API FormatNum
Use it as below
Source field --> FormatNum --> Target Field
http://java.sun.com/j2se/1.3/docs/api/java/text/DecimalFormat.html
Thanks
Swarup
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
The Code is as Below.
************************************************
int decPos = input.indexOf(".");
String beforeDecimal = input.substring(0,decPos);
for (int i = beforeDecimal.length() ; i<4;i++)
{
beforeDecimal = "0" + beforeDecimal;
}
return beforeDecimal;
**********************************************************************
Regards,
MZ
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jayaram,
May i know what is the use of zero's before the number. To round the value use abs funtion in math class in java api. If you want to need zero's you have to write logic after the . keep the before the number.
But there is no method in java api to do the functionality what you have told. You have to implement your own logic.
I think zero's are not required.
Thanks,
RamuV
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.