code: public static long parseLong(String val, long defValue){
          if(TextUtils.isEmpty(val)) return defValue;
          try{
              return Long.parseLong(val);
          }catch (NumberFormatException e){
              return defValue;
          }
      }
docs: Parse a long from a String in a safe manner.
  
  @param val           the string to parse
  @param defValue      the default value to return if parsing fails
  @return              the parsed long, or default value