code: public static long bytesToLongPad(byte[] bytes) {
          final int padZeros = Math.max(8-bytes.length, 0);
          ByteBuffer bb = ByteBuffer.allocate(8);
          for(int i=0; i<padZeros; i++) {
              bb.put((byte)0);
          }
          bb.put(bytes, 0, 8-padZeros);
          bb.flip();
          return bb.getLong();
      }
docs: Call this if you have a byte array to convert to long, but your array might need
  to be left-padded with zeros (if it is less than 8 bytes long).