title: Format an Integer using Java String Format
body: <p>I am wondering if it is possible, using the String.format method in Java, to give an integer preceding zeros?</p>
  
  <p>For example:</p>
  
  <p>1 would become 001<br/>
  2 would become 002<br/>
  ...<br/>
  11 would become 011<br/>
  12 would become 012<br/>
  ...<br/>
  526 would remain as 526<br/>
  ...etc<br/></p>
  
  <p>At the moment I have tried the following code:</p>
  
  <pre><code>String imageName = "_%3d" + "_%s";
  
  for( int i = 0; i &lt; 1000; i++ ){
      System.out.println( String.format( imageName, i, "foo" ) );
  }
  </code></pre>
  
  <p>Unfortunately, this precedes the number with 3 empty spaces. Is it possible to precede the number with zeros instead?</p>