cancel
Showing results for 
Search instead for 
Did you mean: 

UDF SOME JAVA CODE REQUIRE

Former Member
0 Kudos

HI

Experts

i need to help of writing udf

my source value is :000234 result willbe 234

023456 23456

004537 4537

like this how can i achive this ; my source as fixedlength is 6 digts as string

any expert can help me

thanks&ragards

kumar

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

/******UDF********/

String a= "000234";

int pos= 0;

for(int i=0;i<a.length();i++){

if(Character.isDigit(a.charAt(i))&& !a.substring(i,i+1).equalsIgnoreCase("0")){

pos = i;

break;

}

}

return( a.substring(pos));

Please check this code.

Cheers!

Samarjit

Former Member
0 Kudos

hi

samarjit

vy exlent job

one sigle line code

thanks u vy much

regards

kumar

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi-

Try this program

public static String removeLeadingZeros(String str) {

if (str == null) {

return null;

}

char[] chars = str.toCharArray();

int index = 0;

for (; index < str.length; index++) {

if (chars[index] != '0') {

break;

}

}

return (index == 0) ? str : str.substring(index);

}

Note: Here 'str' in the string you are passing

former_member335553
Active Contributor
0 Kudos

Hi

have u tried with 'formatNum' function in the arithmetic functions....as a parameter to this function just put '#'...

also check for the The Function Round ( under Arithmetic ) might help you

if trying with UDF u can go for

String output = inputVal.replaceFirst("^0+","");

return output;

or also

int Seq = Integer.parseInt(inputVal)

This will suppress all the leading zeroes