Source:
<code>public void initialize() throws MessageFormatException, IOException { byte[] usermetadata = new byte[2000]; byte[] blob = new byte[4000]; new Random().nextBytes(usermetadata); new Random().nextBytes(blob); long sizeToWrite = 0; BlobProperties blobProperties = new BlobProperties(4000, "test", "mem1", "img", false, 9999); expectedExpirationTimeMs = BlobPropertiesUtils.getExpirationTimeInMs(blobProperties.getCreationTimeInMs(), <START> blobProperties.getTimeToLiveInSeconds()); <END> PutMessageFormatInputStream msg1 = new PutMessageFormatInputStream(keys[0], blobProperties, ByteBuffer.wrap(usermetadata), new ByteBufferInputStream(ByteBuffer.wrap(blob)), 4000); PutMessageFormatInputStream msg2 = new PutMessageFormatInputStream(keys[1], new BlobProperties(4000, "test"), ByteBuffer.wrap(usermetadata), new ByteBufferInputStream(ByteBuffer.wrap(blob)), 4000); PutMessageFormatInputStream msg3 = new PutMessageFormatInputStream(keys[2], new BlobProperties(4000, "test"), ByteBuffer.wrap(usermetadata), new ByteBufferInputStream(ByteBuffer.wrap(blob)), 4000); TTLMessageFormatInputStream msg4 = new TTLMessageFormatInputStream(keys[0], -1); DeleteMessageFormatInputStream msg5 = new DeleteMessageFormatInputStream(keys[1]); PutMessageFormatInputStream msg6 = new PutMessageFormatInputStream(keys[3], new BlobProperties(4000, "test"), ByteBuffer.wrap(usermetadata), new ByteBufferInputStream(ByteBuffer.wrap(blob)), 4000); buffer = ByteBuffer.allocate((int)(msg1.getSize() + msg2.getSize() + msg3.getSize() + msg4.getSize() + msg5.getSize() + msg6.getSize() / 2)); writeToBuffer(msg1, (int)msg1.getSize()); writeToBuffer(msg2, (int)msg2.getSize()); writeToBuffer(msg3, (int)msg3.getSize()); writeToBuffer(msg4, (int)msg4.getSize()); writeToBuffer(msg5, (int)msg5.getSize()); writeToBuffer(msg6, (int)msg6.getSize() / 2); buffer.position(0); }</code><technical_language>Lets create BlobPropertiesUtils. Utils provide generic methods. getExpirationTimeInMs in Utils</technical_language>

Target:
public void initialize() throws MessageFormatException, IOException { byte[] usermetadata = new byte[2000]; byte[] blob = new byte[4000]; new Random().nextBytes(usermetadata); new Random().nextBytes(blob); long sizeToWrite = 0; BlobProperties blobProperties = new BlobProperties(4000, "test", "mem1", "img", false, 9999); expectedExpirationTimeMs = Utils.addSecondsToEpochTime(blobProperties.getCreationTimeInMs(), blobProperties.getTimeToLiveInSeconds()); PutMessageFormatInputStream msg1 = new PutMessageFormatInputStream(keys[0], blobProperties, ByteBuffer.wrap(usermetadata), new ByteBufferInputStream(ByteBuffer.wrap(blob)), 4000); PutMessageFormatInputStream msg2 = new PutMessageFormatInputStream(keys[1], new BlobProperties(4000, "test"), ByteBuffer.wrap(usermetadata), new ByteBufferInputStream(ByteBuffer.wrap(blob)), 4000); PutMessageFormatInputStream msg3 = new PutMessageFormatInputStream(keys[2], new BlobProperties(4000, "test"), ByteBuffer.wrap(usermetadata), new ByteBufferInputStream(ByteBuffer.wrap(blob)), 4000); TTLMessageFormatInputStream msg4 = new TTLMessageFormatInputStream(keys[0], -1); DeleteMessageFormatInputStream msg5 = new DeleteMessageFormatInputStream(keys[1]); PutMessageFormatInputStream msg6 = new PutMessageFormatInputStream(keys[3], new BlobProperties(4000, "test"), ByteBuffer.wrap(usermetadata), new ByteBufferInputStream(ByteBuffer.wrap(blob)), 4000); buffer = ByteBuffer.allocate((int)(msg1.getSize() + msg2.getSize() + msg3.getSize() + msg4.getSize() + msg5.getSize() + msg6.getSize() / 2)); writeToBuffer(msg1, (int)msg1.getSize()); writeToBuffer(msg2, (int)msg2.getSize()); writeToBuffer(msg3, (int)msg3.getSize()); writeToBuffer(msg4, (int)msg4.getSize()); writeToBuffer(msg5, (int)msg5.getSize()); writeToBuffer(msg6, (int)msg6.getSize() / 2); buffer.position(0); }