code: public static long getBytesLongValueSafely(byte[] bytes, int offset,
              int length) {
          assert length <= 8 && length >= 0 && bytes != null;
          byte[] value = new byte[length];
          if (offset + length > bytes.length) {
              logger.warn("byte array not large enough for given offset + length");
          }
          for (int i = 0; offset + i < bytes.length && i < length; i++) {
              value[i] = bytes[offset + i];
          }
          return bytesToLong(value);
      }
docs: Retrieves the long value of a subarray of bytes.
  <p>
  The values are considered little endian. The subarray is determined by
  offset and length. If bytes length is not large enough for given offset
  and length the values are considered 0.
  <p>
  This should be used for file format fields, where part of the value has
  been cut. Example: TinyPE
  <p>
  Presumes the byte array to be not null and its length should be between 0
  and 8 inclusive.
  
  @param bytes
  the little endian byte array that shall be converted to long
  @param offset
  the index to start reading the long value from
  @param length
  the number of bytes used to convert to long
  @return long value