DateTime vs. DateTimeType (OpenHAB 3.x)

Upgrading from OH 2.x to 3x and have questions about DateTime vs. DateTimeType when/where to use each. In the URL below, it references both of them but doesn’t clearly tell you which to use when/where.

In my .items file, I have DateTime defined for items. Do I change these to DateTimeType ?

In my .rules file, I have variables defined as DateTime. Do I change these to DateTimeType ?

I have changed some of the variables over in my .rules file which resulted in the compiled errors going away.

var	DateTimeType	Cal_Date0				=
var	DateTimeType	Cal_Date1				=
var	DateTimeType	Cal_Date2				=
var	DateTimeType	Cal_Date3				=
var	DateTimeType	Cal_Date4				=

this works also

var 				Cal_Date0 = new DateTimeType()
var 				Cal_Date1 = new DateTimeType()
var 				Cal_Date2 = new DateTimeType()
var 				Cal_Date3 = new DateTimeType()
var 				Cal_Date4 = new DateTimeType()

Best, Jay

It’s actually pretty easy. DateTime is an Item Type. You’d only ever use it in a .items file.

DateTime type is the type for the State carried by a DateTime Item.

In rules in OH 3, there is no longer such a thing as DateTime. That came from a library that has been deprecated for years and was finally removed in OH 3. Instead of org.joda.time.DateTime you will use java.time.ZonedDateTime.

The two work mostly the same but there are some differences covered in the lists of breaking changes. There are also several postings on the forum showing how to use ZonedDateTime.