ByteBuffer (int payloadLength, @NotNull Random random) { ByteBuffer byteBuffer = ByteBuffer.allocate(TIMESTAMP_LENGTH + payloadLength); long utc = ZonedDateTime.now(ZoneOffset.UTC).toInstant().toEpochMilli() / 1000; int timestamp = (int)(utc - EPOCH); byteBuffer.putInt(timestamp); byte[] bytes = new byte[payloadLength]; random.nextBytes(bytes); byteBuffer.put(bytes); return byteBuffer; }