rule "Kiedy andzia opuszcza dom"
when
Item iPhone_Andzia_Home_own changed from ON to OFF
then
val aktual4 = transform("MAP", "lokalizacja.map", iPhone_Andzia_Home_own.state.toString)
iPhone_Andzia_Home_full.postUpdate(aktual4 + " od " + now.toString("HH:mm,dd.MM"))
iPhone_Andzia_Home.postUpdate(OFF)
end
But now in OH3 this rule doesnt formatting DateTime as
In OH3, now() returns a java.time.ZonedDateTime. You can also get the current time by creating an instance of DateTimeType, which also has a zonedDateTime method to get a ZonedDateTime. A ZonedDateTime has a format method that takes a DateTimeFormatter and returns a formatted string…
import java.time.format.DateTimeFormatter// put at top of file
...
iPhone_Andzia_Home_full.postUpdate(aktual4 + " od " + now().format(DateTimeFormatter.ofPattern("HH:mm,dd.MM")))
in my ECMA-Script in the “Then”-Part, I get
failed: :1:0 Expected an operand but found import
Without the import it seems like I can’t use the “now”-object. How can I declare this import?