title: In Java, how do I check if input is a number?
body: <p>I am making a simple program that lets you add the results of a race, and how many seconds they used to finish. So to enter the time, I did this:</p>
  
  <pre><code>int time = Integer.parseInt(JOptionPane.showInputDialog("Enter seconds"));
  </code></pre>
  
  <p>So my question is, how can I display an error message to the user if he enters something other than a positive number? Like a MessageDialog that will give you the error until you enter a number. </p>