Parse String to DateTime object

What is working now is the following code:

    var DateTime dtHeizungsanlage = parse(HzgAnlage_DateString.state + "T" + HzgAnlage_TimeString.state)
    val dtAktuell = new DateTime((Datum.state as DateTimeType).calendar.timeInMillis)
    var boolean bSyncroInaktiv = dtAktuell.isAfter(dtHeizungsanlage.plusSeconds(180)) 

I don’t know why I have to create first a new DateTime object with “dtAktuell” because “Datum” is already a DateTime item (defined in the *.items file) and transform it to milliseconds to work correctly. For me it seems to work with date and time objects in rules is a pain in my ass.