Basically, neither work. I managed to get the .toString not to error on the console, however it didn’t format correctly, and also it removed everything that I added onto the MQTT message after that (when I used the + operator to add more text).
var String day = Weather_Forecast_Day_1.state.format("%1$tA")
WeatherMQTT_1.postUpdate(day)
Hopefully that should work, I quickly tested it in my setup with the following:
rule "test"
when
Item test_switch changed to ON
then
dateTime.postUpdate(new DateTimeType())
end
rule "test"
when
Item dateTime received update
then
var String tmp = dateTime.state.format("%1$tA")
logInfo("dateTime",tmp)
end
With it having passed midnight for us Brits, my version printed out “Tuesday”.