nifi-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James McMahon <>
Subject Get YYYY from java.sql.Timestamp (jython engine, ExecuteScript)
Date Thu, 22 Feb 2018 12:17:06 GMT
Hello. I have a java.sql.Timestamp object in a python script being executed
by the python engine of ExecuteScript. As has been explained to me, the
underpinnings of this appears to be jython.

I need to get YYYY, MM, and DD from this java.sql.Timestamp object, ,myDT.
I've done research and discovered that the trick to doing this is to first
take your timestamp object and put it into a Calendar object. Like this
(credit StackOverflow,

Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(myDT);return cal.get(Calendar.YEAR);

In an effort to do this I must import the Calendar class. I tried this:
import java.util.Calendar
and it failed, and I tried this
import Calendar
and it failed.

Error thrown by NiFi is this:

no viable alternative at input 'cal' in script at line number

How do I get the year from my timestamp object in python code
running in an ExecuteScript processor that employs jython?

Thanks very much.

View raw message