@Override
    protected Long map(final Traverser.Admin<S> traverser) {
        final Object object = traverser.get();
        OffsetDateTime date;
        OffsetDateTime otherDate;

        if (!(object instanceof OffsetDateTime)) {
            // allow incoming traverser to resolve into Date object for compatibility
            if (object instanceof Date) {
                date = ((Date) object).toInstant().atOffset(ZoneOffset.UTC);
            } else {
                // note: null handling consistency to be resolved https://issues.apache.org/jira/browse/TINKERPOP-3152
                throw new IllegalArgumentException(
                        String.format("DateDiff can only take OffsetDateTime or Date (deprecated) as argument, encountered %s", object.getClass()));
            }
        } else {
            date = (OffsetDateTime) object;
        }


        if (null == value && null != dateTraversal) {
            Object traversalDate = TraversalUtil.apply(traverser, dateTraversal);
            if (traversalDate == null) {
                otherDate = null;
            } else if (traversalDate instanceof Date) {
                // for cases when traversal resolves to a java.util.Date object (e.g. inject(new Date()))
                otherDate = ((Date) traversalDate).toInstant().atOffset(ZoneOffset.UTC);
            } else if (traversalDate instanceof OffsetDateTime) {
                otherDate = (OffsetDateTime) traversalDate;
            } else {
                throw new IllegalArgumentException(String.format("DateDiff can only take OffsetDateTime or Date (deprecated) as argument, encountered %s", object.getClass()));
            }
        } else {
            otherDate = value;
        }

        // let's not throw exception and assume null date == 0
        return otherDate == null ? date.toEpochSecond() : Duration.between(otherDate, date).getSeconds();
    }
Reference implementation for date difference step.

@author Valentyn Kahamlyk
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/DateDiffStep.java