class PostmanService {

    Optional<Instant> getStartDateTime(Response response) {
        if (response == null) {
            return Optional.empty();
        }
        // @see https://tools.ietf.org/html/rfc7231#section-7.1.1.2
        return Arrays.stream(response.getHeader())
                .filter(header -> "Date".equalsIgnoreCase(header.getKey()))
                .findFirst()
                .map(KeyValue::getValue)
                .map(value -> {
                    try {
                        return ZonedDateTime.parse(value, DateTimeFormatter.RFC_1123_DATE_TIME).toInstant();
                    } catch (DateTimeParseException e) {
                        log.error("Cannot parse date from response header in Newman report: {}", value, e);
                        return null;
                    }
                });
    }

}