You can convert a String to long using parseLong() method of Integer wrapper class or using valueOf() and longValue() methods together as follows.

 long l = Long.valueOf(str).longValue();
   or
   long l = Long.parseLong(str);