title: Convert timestamp string to long in java
body: <p>I have to fetch time stamp from DB and retrieve only time and compare two time.</p>
  
  <p>//below are the string values</p>
  
  <pre><code> String st1 = "2015-07-24T09:39:14.000Z";      
   String st2 = "2015-07-24T09:45:44.000Z";
  </code></pre>
  
  <p>//retrieving only time <strong>09:39:14</strong></p>
  
  <pre><code> String s = st1.substring(st1.indexOf("T") + 1, st1.indexOf(".0"));
  </code></pre>
  
  <p>//string to Long.    </p>
  
  <pre><code> Long time = Long.parseLong(s);
  
   Long tim1=Long.valueOf(s).longValue();
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>java.lang.NumberFormatException.forInputString(Unknown Source)
      at java.lang.Long.parseLong(Unknown Source)
      at java.lang.Long.parseLong(Unknown Source)
  </code></pre>