Using Python datetime functions in Jython script processor leads to exception: "AttributeError: 'java.sql.Timestamp' object has no attribute 'timetuple'".


Userlevel 4
Badge

Issue:

In Jython script processor script body, using Python datetime function such as datetime.strptime() returns 'java.sql.timestamp' object instead of a datetime.datetime object.  Consequently, using a Python datetime method upon this object results in the following exception:

AttributeError: 'java.sql.Timestamp' object has no attribute 'timetuple'

 

Cause: 

The behavior is a result of this open JSR-223/Jython bug.  The JSR-223 script engine is used in SDC to do the Jython code execution.

 

Workaround:

As a workaround, you can use different Python functions to accomplish this same, use Java API methods (some are accessible as part of the script engine Java interop), or use a different script processor.


0 replies

Be the first to reply!

Reply