im using OH2 for a while now .
Now i am again at a point where i need help.
This:
val String transdatetimePOWR2 = LastUpdatePOWR2.state.format("%1$td.%1$tm.%1$tY")
LastUpdateFromDateTimeTypePOWR2.postUpdate(transdatetimePOWR2)
converts “2020-08-06T20:50:24.092+02:00” to this “2020-08-06” which works fine.
Now i am trying to convert a “now.createTimer” value “2020-08-06T20:50:24.092+02:00” instead of the “LastUpdatePOWR2” variable to a readable format “2020-08-06 20:50:24”.
When i use the same two lines and putting the now.createTimer value instead of the “LastUpdatePOWR2” i get the following error message: “Rule ‘Test Timer Set 1’: ‘format’ is not a member of ‘org.joda.time.DateTime’; line 8, column 49, length 52”
can anyone point me to the step where i can transform the now.createTimer value into a readable YMD HMS format please.
Hi, thnx. I read the post and am quite aware how to transform the values.
What i need is the right Syntax for using the
now.plusMinutes(minutes) value in a conversion rule like this:
val String transdatetimePOWR2 = LastUpdatePOWR2.state.format("%1$td.%1$tm.%1$tY")
LastUpdateFromDateTimeTypePOWR2.postUpdate(transdatetimePOWR2)
Instead of the “LastUpdatePOWR2” i would like to use “now.plusMinutes(minutes)”.
i think “now.plusMinutes(minutes)” needs to be in brackets somehow, cause if you put it in just like it is OH2 throws an error with either state or format in it.
I tried several ways but havent found the right one yet.
Okay, but it’s not very clear to me what you want to accomplish.
What I read is that you want the item LastUpdateFromDateTimeTypePOWR2 represent a datetime value in YMD HMS, based on now plus X minutes, correct?
First of all type of item is LastUpdateFromDateTimeTypePOWR2. If it is a DateTime item, you can use the label to show the human readable view of the date.
To update such a item, you can use this:
var fred = now.plusMinutes(minutes)
// this is a Joda datetime and not the same as Item datetime
// Joda has built-in pattern style formatting
logInfo("test", "stuff " + fred.toString("yyyy-MM-dd' 'HH:mm"))
This is all referenced in the conversions link from @ljsquare