Using python datetime

When I write a python script/rule which uses datetime, this does what I expect:

import datetime
tomorrow = + datetime.timedelta(days=1)

but the following fails with
TypeError: unsupported operand type(s) for +: ‘java.sql.Timestamp’ and 'timedelta’

import datetime
now =
tomorrow = now + datetime.timedelta(days=1)

There seems to be some implicit type conversion going on. I suspect I need to understand better the differences between python and jython… Where do I learn please? And how do I fix the above?


This is an odd behaviour of Jython. Took me a while to find out.

You can google it:

If you assign a datetime object to a variable it is converted to java internally and it messes up the variable attributes.

In my scripts I do not assign datetime object to variables or use java.time

Thank you. Odd and painful! I shall religiously avoid using datetime from now on.