title: Using Javas System.out.format to align integer values
body: <p>I am trying to produce right aligned numbers looking a bit like this:</p>
  
  <pre><code>  12345
     2345
  </code></pre>
  
  <p>but I clearly does not understand the syntax. I have been trying to follow <a href="http://docs.oracle.com/javase/tutorial/java/data/numberformat.html" rel="nofollow">these instructions</a>. and Come up with the following attempt (it is integers so d and I want width 7 and 0 decimals):</p>
  
  <pre><code>public class test {
  
      public static void main( String[] args ) {
          System.out.format("%7.0d%n", 12345);
          System.out.format("%7.0d%n",  2345);
      }
  }
  </code></pre>
  
  <p>but no matter what I do I seem to end up with <code>IllegalFormatPrecisionException</code>. Is there a way to do this using this tool? If not how else would you do it?</p>