on 01-08-2015 8:21 AM
Hi experts,
i had a requirement where i need to send the customer no to the target .the input can be either numeric or alpha numeric or it can be null some times. if it is numeric value i need get input no preceeded by '0' i have tried the following code and it worked for both the alphanumeric input values but it doesnot work for the null values.could you please suggest me . suggested person will be appriciated.
Execution type: single values i have taken
int count = 0;
for (int i = 0; i <= var1.length(); i++)
{
if(!Character.isDigit (var1.charAt(i)))
{
count = count +1;
break;
}
}
if (count>=0)
{
return var1;
}
else
{
String format = String.format("%010d",Integer.parseInt(var1));
return format;
}
Thanks
Giridhar
Hi Girdhar,
Have you tried this?:
int count = 0;
if (var1.length() == 0) {
return null;
}
for (int i = 0; i <= var1.length(); i++)
{
if(!Character.isDigit (var1.charAt(i)))
{
count = count +1;
break;
}
}
if (count>=0)
{
return var1;
}
else
{
String format = String.format("%010d",Integer.parseInt(var1));
return format;
}
You can control the null values at the beginning.
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Giridhar,
Please try with following UDF:
int count = 0;
for (int i = 0; i <var1.length(); i++)
{
if(!Character.isDigit (var1.charAt(i)))
{
count = count +1;
break;
}
}
if (count>0 || var1.length() == 0)
//Updated this IF condn to handle Null input
{
return var1;
}
else
{
String format = String.format("%010d",Integer.parseInt(var1));
return format;
}
Regards,
Azhar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
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.