Please help me format data - time in rules OH2.5 Vs OH4.0

I have a rule with this code in OH 2.5 and the data have this format:

rule "litri"
	when
		Item It_O_StatoElettrov changed
	then
		if(It_O_StatoElettrov.state==ON){
			PrecLitriPiscina10.sendCommand(PrecLitriPiscina9.state.toString)
			PrecLitriPiscina9.sendCommand(PrecLitriPiscina8.state.toString)
			PrecLitriPiscina8.sendCommand(PrecLitriPiscina7.state.toString)
			PrecLitriPiscina7.sendCommand(PrecLitriPiscina6.state.toString)
			PrecLitriPiscina6.sendCommand(PrecLitriPiscina5.state.toString)
			PrecLitriPiscina5.sendCommand(PrecLitriPiscina4.state.toString)
			PrecLitriPiscina4.sendCommand(PrecLitriPiscina3.state.toString)
			PrecLitriPiscina3.sendCommand(PrecLitriPiscina2.state.toString)
			PrecLitriPiscina2.sendCommand(PrecLitriPiscina1.state.toString)
			PrecLitriPiscina1.sendCommand(LitriPiscinaOP.state.toString)
		 
    } else {
			LitriPiscinaOP.sendCommand(now.toString("dd-MM-yyyy'  'HH:mm:ss") + " Litri " + LitriPiscina.state.toString)
		}
	end

The same code in OH 4.0 show this

There is a new format of data and time?
How i can fix it as the first image for format data?

Try this

 else {
   val formatter = java.time.format.DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm:ss")
   LitriPiscinaOP.sendCommand(now.format(formatter) + " Litri " + LitriPiscina.state.toString)
		}
1 Like

yeahhhhhh many thanksssss!!!