@Override
    protected OffsetDateTime map(final Traverser.Admin<S> traverser) {
        final Object object = traverser.get();
        if (object == null)
            throw new IllegalArgumentException("Can't parse null as OffsetDateTime.");
        if (object instanceof Date)
            return OffsetDateTime.ofInstant(((Date) object).toInstant(), ZoneOffset.UTC);
        if (object instanceof OffsetDateTime)
            return (OffsetDateTime) object;
        if (object instanceof Byte || object instanceof Short || object instanceof Integer || object instanceof Long)
            // numbers handled as milliseconds since January 1, 1970, 00:00:00 UTC.
            return OffsetDateTime.ofInstant(Instant.ofEpochMilli(((Number) object).longValue()), ZoneOffset.UTC);
        if (object instanceof BigInteger) {
            try {
                return OffsetDateTime.ofInstant(Instant.ofEpochMilli(((BigInteger) object).longValueExact()), ZoneOffset.UTC);
            } catch (ArithmeticException ae) {
                throw new IllegalArgumentException("Can't parse " + object + " as OffsetDateTime.");
            }
        }

        if (object instanceof String) {
            try {
                return DatetimeHelper.parse((String) object);
            }
            catch (DateTimeParseException e) {
                throw new IllegalArgumentException("Can't parse " + object + " as OffsetDateTime.");
            }
        }

        throw new IllegalArgumentException("Can't parse " + object.getClass().getName() + " as OffsetDateTime.");
    }
Reference implementation for date parsing step.

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