I recently had a need to create a zero padded value in JMeter and thought I
would share the Beanshell code I used to get it working.
I wasn't sure why I needed to put the long into a Java Array to make it
work with String.format but this worked for me using a Beanshell Sampler
taking a counter:
String inputcounter = vars.get("InputCounter");
Long[] longarray = new Long[] {Long.valueOf(inputcounter)};
String paddednumber = String.format("%019d", longarray);
vars.put("PaddedCounter",paddednumber);
This will create a padded number up to 19 digits "%019d" change the 19 to
the number of padded digits you need.
This way I could have a JMeter counter with the reference / variable name
"InputCounter" inside a loop, use that value and also create a padded
version of the number as "PaddedCounter".
I am sure there are cleaner ways of doing it but this worked for me :)
Cheers
Peter