Date Time conversion error in a rule

Hi,
I have a rule that work under OH2.4.0 and throw an error on OH3.3.0
I get error when I try to get a DateTime item and assign to a variable.

This is the item:

DateTime SOULISS_TIME_GATEWAY "Gateway Timestamp [%1$td.%1$tm.%1$tY %1$tk:%1$tM:%1$tS]" <"time"> { channel = "remoteopenhab:server:fc64e8fb32:SOULISS_TIME_GATEWAY" }
String SOULISS_UPD_SINCE_GATEWAY "Gateway Non aggiornato da [%s sec.]" <"time">

And this is the part of the rule:

        var DateTime adesso = now
	//Gateway
	var Integer gw_diff = 0
	try{
		//var DateTime dt_gateway = new DateTime(SOULISS_TIME_GATEWAY.state.toString)
		var DateTime dt_gateway = new DateTime(SOULISS_TIME_GATEWAY.state)
		gw_diff = (adesso.millis.intValue - dt_gateway.millis.intValue) / 1000
	}catch (Exception exc) {
    	gw_diff = -1
    }
    SOULISS_UPD_SINCE_GATEWAY.postUpdate(gw_diff)

When rule is esecuted i got this:

2022-07-18 10:49:24.922 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'souliss-3' failed: An error occurred during the script execution: null in souliss

I checked that DateTime item is populated with values.
Many thanks in advance

Marco

Date Time handling changed between oh2.4 and oh3

Please see examples here: