cancel
Showing results for 
Search instead for 
Did you mean: 

Help regarding UDF.

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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