title: Cannot convert String to Integer in Android Studio / Java
body: <p>I have a function that receives a number (milliseconds to be precise) via Bluetooth.</p>
  
  <pre><code>byte[] encodedBytes = new byte[readBufferPosition];
  System.arraycopy(readBuffer, 0, encodedBytes, 0, encodedBytes.length);
  final String data = new String(encodedBytes, "UTF-8");
  readBufferPosition = 0;
  
  started = "";
  int myInt;
  if (data != "") {
    try{
      myInt = new Integer(data);
      long seconds = TimeUnit.MILLISECONDS.toSeconds(myInt);
    }catch(NumberFormatException ex){
      System.err.println("NumberFormatException "+ ex.getMessage());
    }
    ...
  } else {
    ...
  }
  </code></pre>
  
  <p>The above try throws: </p>
  
  <pre><code>NumberFormatException Invalid int: "8250
  </code></pre>
  
  <p>I think the data received contains more then just the milliseconds, but how can I find that out, when I do</p>
  
  <pre><code>myLabel.setText(data);
  </code></pre>
  
  <p>it shows me: <code>8250</code></p>
  
  <p>Any ideas?</p>