[SOLVED] Current time in rule

How can i get the current time in hh:mm:ss in rule to append on a string item to display in habpanel? The topics I read in this bolg produces all errors.

This al depends on what exactly you are trying to achieve. If you could describe in more detail what you need, people can come up with the most appropriate solution

At last I found the solution:

rule “Pumpenstatus"
when
Item Pumpe_Status changed
then
if ( Pumpe_Status.state == ON )
{
val String currentTime = String::format( “%1$tH:%1$tM”, new java.util.Date )
Pumpe_Label.postUpdate(“Pumpe läuft seit " + currentTime)
executeCommandLine(”/usr/local/bin/openhab2/writelog.sh Pumpe an”)
}
if ( Pumpe_Status.state == OFF )
{
Pumpe_Label.postUpdate(“Pumpe ist aus”)
executeCommandLine("/usr/local/bin/openhab2/writelog.sh Pumpe aus")
}
end

Thanks :slight_smile: