title: How to find a host ping time
body: <p>I'm trying to find the ping time (using Windows 8, Java 6). I'm using System.currentTimeMillis() method to find a ping time, but it return a strange values. For example when I'm pinging a localhost it returns 1000 ms. </p>
  
  <p>Please help me to create a routine that finds a host ping time.</p>
  
  <pre><code>public int pingHost(String host){
      Long start = System.currentTimeMillis();
      if (!InetAddress.getByName(host).isReachable(2000)) return -1;
      return (int) (System.currentTimeMillis()-start);
  }
  </code></pre>
  
  <p>P.S. This question is not a dublicate of <a href="https://stackoverflow.com/questions/2448666/how-to-do-a-true-java-ping-from-windows">How to do a true Java ping from Windows?</a>
  It's not enough to me just check the is host online or not. I need to measure the connection speed and find a "ping time" value.</p>