code: static public long asLongValue(byte[] array, int offset, int length) {
          if (null == array || array.length <= offset) {
              return -1L;
          }
  
          long longVal = 0;
          long mark = 1;
          int digit;
          int i = offset + length - 1;
          // ignore trailing whitespace
          for (; offset <= i; i--) {
              char c = (char) array[i];
              if (BNFHeaders.SPACE != c && BNFHeaders.TAB != c) {
                  break;
              }
          }
          for (; offset <= i; i--) {
              digit = array[i] - ZERO;
              if (0 > digit || 9 < digit) {
                  // stop on any nondigit, if it's not a DASH then throw an exc
                  if (DASH != array[i]) {
                      throw new NumberFormatException("Invalid digit: " + array[i]);
                  }
                  break;
              }
              longVal += digit * mark;
              mark *= 10;
          }
  
          // check for negative numbers
          if (offset <= i && array[i] == DASH) {
              longVal = -longVal;
          }
  
          return longVal;
  
      }
docs: Take an input byte[] and return the long translation. For example, the
  byte[] '0053' would return 53.
  
  @param array
  @param offset into the array to start at
  @param length number of bytes to review
  @return long
  @throws NumberFormatException (if the data contains invalid digits)