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

  • 24 May 2022
  • 0 replies
  • 40 views

Userlevel 3

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