zero pad string in groovy script
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2018
01:08 PM
04-11-2018
01:08 PM
zero pad string in groovy script
in my Groovy script I want to format an integer as a zero padded string. Something like:
def row = 27 log.info "zero padded = " + Format("%04i", row)
can it be done?
Solved! Go to Solution.
1 REPLY 1
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2018
01:57 PM
04-11-2018
01:57 PM
Hey, this can be done quite simply:
def row = 27 def paddedRow = String.format("%010d", row)
log.info paddedRow
By "%010d" you specify how many digits do you want your number to have.
Lucian.
If my answer helped please click on the 'Accept as Solution' button.
