Subtracting dates

Forgive me if I am missing something obvious, but is there a way to subtract one java.util.Date from another to compute a duration? I don't see anything in the system.date functions that would accomplish that.

alternatively can I convert java.util.Date to python datetime so I can use that library?

I have been pounding my head against the wall all morning, but it is Monday :blush:

Thanks!

Sure there is, use the system.date.*Between() functions. For instance if you want to know the hours between two dates, then you would do something like:

system.date.hoursBetween(firstDate,secondDate)
6 Likes

That worked, thank you!

Psst! Don't ever use this in jython--it isn't up to date and never will be.

4 Likes