on 09-22-2008 1:47 PM
Hi,
My UDFscenario is to get the prepend zero's for array of string. I am passing the String[] as input for prepend zero function.please provide me a code.
Hi,
If u have same length (for example in this code i assumed as 20 ) Strings in your input array..then this code will work
Take type of UDF as queue type
then the UDF will be of type void
Use this code
Here a[] =input array
b[] =output array
so here you have to pass 2 arguments to your UDF
for(int i=0;i<a.length;i++)
{
int Arraylength=a<i>.length();
int length=20-Arraylength;
if(length>0)
{
String temp="";
for(int i=0;i<length;i++)
temp=temp.concat("0");
}
b<i>=temp.concat(a<i>);
result.addValue(b<i>);
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hii
1) A clean solution for this avoiding cutom UDFs is using formatNumber arithmetic function with the format "000000000000000000".
It will format the number padding 0.
2)
If u want really to write UDF :
String strE = "12";
int lenE = strE.length();
for(int i=0;i<18-lenE;i++){
strE="0"+strE;
}
return(strE);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.