Trying to use format in rules

Hi Guys,

going crazy again over transforming values in a rule… Need additional Eyes to see my error, please.
I searched tzhe forum over and over, tried many solutions shown here, but none worked for me.
I am trying to format a value from a DateTime item.
in the end i would like to combine 2 Values into one item.

The string item ConditionID2 that is converted through a MAP conversion:
val trans = transform(“MAP”, “”, Condition_ID2.state.toString) Condition_ID2formatted.postUpdate(trans)
This works like a charm and gives me the term “Bedeckt” which shows perfect in the Basic UI.

The second item is the DateTime item LastUpdate which shows perfectly when displayed with the format options shown here:
DateTime LastUpdate “Last update [%1$td.%1$tm.%1$tY %1$tH:%1$tM]” {weather=“locationId=roedermark, type=condition, property=lastUpdate”}
When i insert this item to display in the Basic UI it shows perfectly formatted:
Text item=LastUpdate shows " 24.11.2019 15:34"

How can i format the DateTime item LastUpdate in a rule to display it in the format shown above?
This is the output string i have in my rule:
Wetter1OutputString.postUpdate(Condition_ID2formatted.state + " (" + LastUpdate.state.toString + “)”)

Condition_ID2formatted.state is allready converted and displays the right value. LastUpdate is in “raw” format as a DateTime item.
Bedeckt (2019-11-24T15:34:37.136+…)
I tried a lot of stuff, but none worked. Please spare a peek and point me in the right direction how to format the LastUpdate item in the rule like it does when displayed directly with formatting in BasicUI.

here is a great thread by Rud that will help you

in this thread I give an example and some more resources

On my phone right now but search the forum for DateTime conversion

Thnx for the replies. I tried the DateTime Conversion Thread before and got no good results. I will try again and post the rule if i dont succeed again :slight_smile:
But maybe, like with my problems before in code, posting here will be enough to succeed this time. :slight_smile:

If i dont get any usable values i will post again with the rules.

well you first have to split out just the date part, use a rule, then write just the date to a DateTime item and format it using the same format string you use on the other item

Yeah…just tried again with the DateTime conversion page examples… and guess what…it worked…
val String transdatetime = LastUpdate.state.format("%1$td.%1$tm.%1$ty %1$tH:%1$tM")
did it.
I did this before, numerous times…well my solution is: Search the community for examples,try coding, try coding, try coding, post a help message, and try coding again, success :slight_smile:

Maybe i tried the same with these lines before:
val String LastUpdateFromDateTimeType = LastUpdate.state.format("%1$td.%1$tm.%1$ty %1$tH:%1$tM")
and i didnt do the postUpdate stuff…well, anyhow.
This community saved my insanity various times now.
A BIG Thank You for doing this.