title: Java String Format: "%0" and "d%s"
body: <p>I would like to know what is the meaning of <code>"%0"</code> and <code>"d%s"</code> in java when formatting a <code>string</code>.       </p>
  
  <pre><code>String.format("%0"+ (8 - "Apple".length() )+"d%s",0 ,"Apple"); 
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>000Apple
  </code></pre>
  
  <p>I was searching for a way to format a string with leading zeros, and that code does the work, but I don't know why it works.</p>
  
  <p>Found that line of code here:<br>
  <a href="https://stackoverflow.com/questions/4051887/how-to-format-a-java-string-with-leading-zero">How to format a Java string with leading zero?</a></p>