Openhab2: how to use now.millis

Hello,
I use a global Variable in the riules:
var long Licht_Carport_start = now.millis

Log:
Variable ‘Licht_Carport_start’ on rule file ‘haus.rules’ cannot be initialized with value ‘.millis’: An error occured during the script execution: The name ‘now’ cannot be resolved to an item or type.

What do I have to include to make that working?
I allready have:
import org.joda.time.*

Thanks

Hello!

I’m not 100% sure, but I think you should use
import java.util.Date

I’m not using now.millis, but I have more than a few now.plusSeconds, and the only import I have is this one.

Best regards,
Davor

On another thread someone was noticing and having a problem with the fact that it takes a little bit before now becomes usable. At the time that the rules file is loaded and parsed now is not yet available for use so it can’t populate that var yet.

They initialized the val to null and then check for null in the rules and set it to now.millis at that point. However, it can’t be a long to do that, you will either have to store it as Long or just store the Joda DateTime.

O.K., so it’s the “now”.
I changed it like you said, and went on to use Number Items instead of global variables. But I now have a problem with casting/conversion of the Number item to do calculations with it.
please see: Need help Number conversion/casting
Thanks!