title: Why am I receiving IllegalFormatConversionException in Java for this code?
body: <p>I am currently working on a code that takes data from the network and print it out on a JTextArea. In between, I am trying to alignment the number based on the decimal position. This is the code that works before implementing the decimal alignment:</p>
  
  <pre><code>private static final String NewLine = System.getProperty("line.separator");
  String NetString = "";
  byte[] data = p.getData();
  NewString += "SID:     " + BuildShort(data,4) + NewLine;
  NewString += "DID:     " + BuildShort(data,6) + NewLine;
  </code></pre>
  
  <p>And this is the new one</p>
  
  <pre><code>NewString += String.format("%-8s%11.5f" + NewLine, "SID    : ", BuildShort(data,4));
  NewString += String.format("%-8s%11.5f" + NewLine, "DID    : ", BuildShort(data,6));
  </code></pre>
  
  <p>which I received the error message</p>
  
  <pre><code>Exception in thread "Thread-2" java.util.IllegalFormatConversionException: f != java.lang.Integer
  at java.util.Formatter$FormatSpecifier.failConversion(Unknown Source)
  at java.util.Formatter$FormatSpecifier.printFloat(Unknown Source)
  at java.util.Formatter$FormatSpecifier.print(Unknown Source)
  at java.util.Formatter.format(Unknown Source)
  at java.util.Formatter.format(Unknown Source)
  at java.lang.String.format(Unknown Source)
  at MT302.ParsePacket(MT302.java:97)
  at MK20_DataView.run(MK20_DataView.java:261)
  at java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>Do you know why I am receiving this error?</p>