title: Java: What's the difference between format specifiers %x and %h?
body: <p>Looking at the <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Formatter.html#syntax">specification page</a>, I see that <code>%h</code> calls into <a href="http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Integer.html#toHexString%28int%29">Integer.toHexString()</a>, but I can't find any practical difference between the two specifiers.</p>
  
  <p>Can you give an example where using the to specifiers on the same input yields different results?</p>
  
  <pre><code>System.out.println(String.format("%1$h %1$x", 123));
  </code></pre>
  
  <p>This prints </p>
  
  <pre><code>7b 7b
  </code></pre>