Create a DateTime item and set its value from another source

I use Wu API to show certain enviroment data in OH. I also obtain the time the measurement was taken from the WU API for this data. The measurements can be up to 15 minutes old ( or updated every 15 minutes) and i poll data every 5 minutes.
So now i would like to take the timestamp from WU and update the DateTime item in OH with it.
Simply updating the DateTime item on every update is not desireable. What i would like is to take the timestamp of the measurement from the WU api and format it in a way that OH can do something with it(e.g. Calulate how old is the data and change valuecolor accordingly etc).

But i couldnt find how i should format (what is the syntx) the OH date time stamp value so that OH would accept it.

Here is an example from my other DateTime item that i update via rules with current time in OH on every update:
From event.log : T_TS state updated to 2016-03-24T22:42:57

The syntax seems pretty straight forward, but the ‘T’ troubles me. iwhat does it stand for? Thursday (today) Time?
Any help or idea or pointers regarding the syntax would be greatly appreciated.

Best regards!

afaik the T stands for Time simply as a separator. I’m not sure if you need to set the timezone !?!

Seems you are right … Today (friday) the updated DateTime item value still shows : T_TS state updated to 2016-03-25T06:10:58

I would be nice though to know the exact syntax that is used to store value to DateTime item, to prevent any unpleasant surprises …

OH uses the Joda library to store and manage DateTime operations. It its base it stores the time value in epoc (i.e. the number of milliseconds since midnight 1/1/1970) and everything else is a calculated from that. Therefore there are all sorts of date time strings that you can pass to a Joda DateTime object that it is able to parse.

Be default if you use:

org.joda.time.DateTime parsedDT = org.joda.time.DateTime::parse(<date time string>)

It will expect the date time to be in ISO format (see this). One of the supported formats is date element T time element which I believe means the format you are seeing is supported.

In your rule you can then use the joda DateTime methods to easily compare this time to other times e.g.:

parsedDT.isBefore(now.minusMinutes(5)) // before 5 minutes ago

Great info! Thanks!