title: How to parse numbers more strict than what NumberFormat does in Java?
body: <p>I'm validating user input from a form.</p>
  
  <p>I parse the input with <a href="http://docs.oracle.com/javase/7/docs/api/java/text/NumberFormat.html" rel="noreferrer"><code>NumberFormat</code></a>, but it is evil and allow almost anything. Is there any way to parse number more strict?</p>
  
  <p>E.g. I would like to not allow these three inputs, for an integer, but <code>Numberformat</code> allow all of them:</p>
  
  <pre><code>NumberFormat nf = NumberFormat.getNumberInstance();
  nf.setParseIntegerOnly(true);
  
  Number numberA = nf.parse("99.731");    // 99 (not what the user expect)
  Number numberB = nf.parse("99s.231");   // 99 (invalid)
  Number numberC = nf.parse("9g9");       // 9  (invalid)
  
  System.out.println(numberA.toString());
  System.out.println(numberB.toString());
  System.out.println(numberC.toString());
  </code></pre>