Padding to get specific number of digits in a number
grails, groovy, java
Solution
In groovy, you can pad Strings like so:
val.padLeft( 7, '0' )
That will pad the left of the string with zeros until it is 7 chars in length
Problem
``` String val = "98" ``` I need to get the output as `0000098` (7 digits). I need left padding of zeros to the string or integer value... The number stored in val is dynamic and may contain any number of digits, but the output should always be 7 digits.