Skip to main content
Announcements
A fresh, new look for the Data Integration & Quality forums and navigation! Read more about what's changed.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Losing leading “0” Zeros when converting to integer from string

Hello,

When I am converting a String to an Integer, I am losing the leading zeros from my variable.
I tried this 'Integer.parseInt((row1.date.length()==5)?"0"+row1.date:row1.date ) ' but it didin't work

Exemple :
Input data : '012005'
In Output data I have : '12005'

Someone can help me please?
Thank you

Labels (2)
1 Solution

Accepted Solutions
cterenzi
Specialist

There's no notion of leading zeroes when storing numbers in a numeric format. If you need to preserve zeroes throughout the job, it has to be a String. If this is only an issue when you output the data at the end, you can convert back to a String, padding the value with leading zeroes as needed.

View solution in original post

2 Replies
vboppudi
Partner - Creator III

Hi Maria,
As per my understanding, if you convert any value to number it will remove '0' zero in the begin. Because there is no value for '0' zero if it is before some number, if zero '0' present after number then it has some value.

Regards,
Veeru
cterenzi
Specialist

There's no notion of leading zeroes when storing numbers in a numeric format. If you need to preserve zeroes throughout the job, it has to be a String. If this is only an issue when you output the data at the end, you can convert back to a String, padding the value with leading zeroes as needed.