private void seek(String topic, int partitionId, long offset) {
            TopicPartition topicPartition = new TopicPartition(topic, partitionId);
            consumer.assign(Collections.singletonList(topicPartition));
            if (offset == ListOffsetsRequest.EARLIEST_TIMESTAMP) {
                consumer.seekToBeginning(Collections.singletonList(topicPartition));
            } else if (offset == ListOffsetsRequest.LATEST_TIMESTAMP) {
                consumer.seekToEnd(Collections.singletonList(topicPartition));
            } else {
                consumer.seek(topicPartition, offset);
            }
        }
Consumer that dumps messages to standard out.
tools/src/main/java/org/apache/kafka/tools/consumer/ConsoleConsumer.java