09-28-2017 06:29 AM
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.
09-29-2017 07:50 AM
Can you post a code snippet of what you tried with the Joda DateTime object that didn’t work?
09-29-2017 09:44 AM
Sure! Here’s a repository full of examples: GitHub - chutch1122/snap-date-issue
Specifically, with Joda’s DateTime object: snap-date-issue/JodaDateTimeSnap.java at master · chutch1122/snap-date-issue · GitHub
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.
12-11-2017 09:51 AM
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.