cancel
Showing results for 
Search instead for 
Did you mean: 

Leading zeros

Former Member
0 Kudos

Hi,

Source is sending some fields with leading zeros , zeros need to be removed in target system.

In mapping any functions are there ana wat are the functions

Regards,

SB

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Write a UDF to remove the zeros

public String RemoveLeadingZeroes(String a,Container container){

String str =a;

String res = "";

String temp = "";

String res1 = "";

char ch[] = null;

int count = 0;

if(str != null)

ch = str.toCharArray();

for(int k=0; k<ch.length;k++)

{

if(ch[k] == '0')

count ++;

}

temp = a.substring(count,count+3);

return temp;

}

Above UDF will help u in solving u r issue

Regards,

Jayasimha Jangam

Answers (4)

Answers (4)

Former Member
0 Kudos

hi,

[]

the above thread might help you to solve ur query.

Regards.

Siddhesh Naik.

Former Member
0 Kudos

Thank you all.

santhosh_kumarv
Active Contributor
0 Kudos

Hi,

No need of UDF. With the standard function you can do this.

Source & constant(1) -


> divide(Arithmetic function) -


> Target

any number with leedin zero's divided or even multiplied by 1 is that number without leeding zero's

Thanks

SaNv...

Former Member
0 Kudos

u can try any of the one in UDF:

Integer.valueOf("000123").toString();

or

String result = Integer.toString(Integer.parseInt(a));

chirag

Former Member
0 Kudos

Write this UDF of cache Value

String str1 = null;

str1 = a.replaceFirst("0*",""); // a is field passed to UDF as parameter

return str1;