Forum Discussion
tstack
8 years agoFormer Employee
Can you provide some more details on what you’re trying to do and what issues you’re running into?
There’s quite a few methods on Date objects in the expression language. Is there something in particular you are looking for?
- doug_fossler8 years agoNew Contributor
Is it not descriptive enough to say i’m attempting to add a time to a date in the script in order to get an example? I’ve tried several methods now to no avail. Here is one of my attempts.
try { load(“nashorn:mozilla_compat.js”); } catch(e) { }
importPackage(com.snaplogic.scripting.language);
importPackage(java.util);
importPackage(java.math);
importPackage(org.joda.time);var impl = {
input : input,
output : output,
error : error,
log : log,execute : function () { this.log.info("Executing Transform Script"); var pid; var pit; var pi; while (this.input != null && this.input.hasNext()) { try { var doc = this.input.next(); pid = doc["punchInDate"]; pit = doc["punchInTime"]; pi = LocalDateTime(pid + ' ' + pit); for (var key in doc) { if (key != "original"){ wrapper.put(key, doc[key]); } } wrapper.put("punchIn", pi); this.output.write(doc, wrapper); } catch(err) { var wrapper = new java.util.HashMap(); wrapper.put("errorMsg", err); this.log.error(err); this.error.write(wrapper); } } }
};
var hook = new com.snaplogic.scripting.language.ScriptHook(impl);