public long timeWaitedForRoll(long now, long messageTimestamp) {
        // Load the timestamp of the first message into memory
        loadFirstBatchTimestamp();
        long ts = rollingBasedTimestamp.orElse(-1L);
        if (ts >= 0)
            return messageTimestamp - ts;
        return now - created;
    }
The time this segment has waited to be rolled.
If the first message batch has a timestamp we use its timestamp to determine when to roll a segment. A segment
is rolled if the difference between the new batch's timestamp and the first batch's timestamp exceeds the
segment rolling time.
If the first batch does not have a timestamp, we use the wall clock time to determine when to roll a segment. A
segment is rolled if the difference between the current wall clock time and the segment create time exceeds the
segment rolling time.
storage/src/main/java/org/apache/kafka/storage/internals/log/LogSegment.java