Strings - Filling In Leading Zeros Wtih A Zero
- by headscratch
I'm reading an array of hard-coded strings of numeric characters - all positions are filled with a character, even for the leading zeros. Thus, can confidently parse it using substring(start, end) to convert to numeric.
Example: "0123 0456 0789"
However, a string coming from a database does not fill in the leading zero with a 'zero character', it simply fetches the '123 456 789', which is correct for an arithmetic number but not for my needs and makes for parsing trouble.
Before writing conditionals to check for leading zeros and adding them to the string if needed, is there a simple way of specifying they be filled with a character ? I'm not finding this in my Java book...
I could have done the three conditionals in the time it took to post this but, this is more about 'education'...
Thanks