You're no doubt treating the code as an integer somewhere along the way, causing of course the leading zeros to be stripped as 0009 as a number is 9. Then when you're converting back somewhere else, you're doing that without prepending leading zeros to guarantee whatever minimum length you're needing.
And none of that is in the code you showed btw.
hi i got situation where i have postal code as 0009 in database and the use is entering 0009 but somehow in my java code it only reading 9 from the xml file
if a user enterd 0009 i what it to remain 0009
What database and version? What is the datatype of the column where postal code is stored.
If a user entered 0009 WHERE? How does the user enter the data? What object is the data entered into?