I have just upgraded from OpenHab 2 and I want to simply format the current time as a string (such as 22-May 22:49)
I had the following code in a rule and this now outputs a long unformatted timestring
val timestamp = now.toString("dd-MMM HH:mm")
logInfo("log.rules", timestamp)
I have tried many things, such as #11 and variations on SimpleDateFormat, but to no avail…
I must be missing something trivial as this cannot be too difficult…
EDIT:
The following works, but is there a simpler solution (without an import)?
import java.time.format.DateTimeFormatter
...
val timestamp = now.format(DateTimeFormatter.ofPattern("dd-MMM HH:mm"))
logInfo("log.rules", timestamp)
...