In Kafka 2.7 the following method was added to AdminClient that provides this information:
|public ListOffsetsResult listOffsets(Map<TopicPartition,OffsetSpec> topicPartitionOffsets,
where OffsetSpec can be:
This ticket introduces a new spec:
|OffsetSpec.MaxTimestampSpec // this returns the offset and timestamp for the record with the highest timestamp.|
This indicates to the AdminClient that we want to fetch the timestamp and offset for the record with the largest timestamp produced to a partition.