Output Date Type in Custom Snap

Is there a way to output a SnapLogic “Date” type (as discussed here: https://docs-snaplogic.atlassian.net/wiki/spaces/SD/pages/1439344/Date+Functions+and+Properties) as a column in a document being written to a snap’s output view?

I would like consumers of the snap to be able to format the dates using toLocaleDateString() / toLocaleDateTimeString() / toLocaleTimeString() without having to Date.parse(…) a string in a mapper first.

I have tried writing Java’s LocalDate, LocalDateTime, and ZonedDateTime as well as Joda-Time’s DateTime objects to the view with no success. Additionally, after any of those date objects are written to the view, none of the remaining columns are written to the output view.

Can you post a code snippet of what you tried with the Joda DateTime object that didn’t work?

Sure! Here’s a repository full of examples: https://github.com/chutch1122/snap-date-issue

Specifically, with Joda’s DateTime object: https://github.com/chutch1122/snap-date-issue/blob/master/src/main/java/com/example/snaps/JodaDateTimeSnap.java#L38-L47

    Map<String, Object> row = new LinkedHashMap<>();

    row.put("firstName", "Bobby");
    row.put("lastName", "Tables");
    row.put("dateOfBirth", new DateTime(1990, 12, 25, 1, 30));
    row.put("email", "bobby@tables.com");
    row.put("yearsExperience", 5);

    Document document = documentUtility.newDocument(row);
    outputViews.write(document);

This is what happens when I run a pipeline with that snap.

Note that none of the properties after dateOfBirth are present (email, yearsExperience) and SnapLogic doesn’t let me format the date.

It looks like a class-loading issue, the class used in your pack is loaded separately from the one in the platform, so the platform doesn’t know how to deal with it. When I unzip the build of the pack I see the joda jar in there, so that is probably why it’s being loaded in and used. You can try adding joda to the pom in the ‘provided’ scope.