Formatting time string

I have these items

DateTime vMorningWeekdays "Morning weekdays [%1$tH:%1$tM]"  //"08:00:00" 
Number vMorningTimeHoursWeekdays "Hour [%d]" <clock> 
Number vMorningTimeMinutesWeekdays "Minute [%d]" <clock> 

In my sitemap I would then like to change my morning time, and i do this by:

	Frame label="Times" {
		Text label="Sunlight" icon="groundfloor" {
			Setpoint item=vMorningTimeHoursWeekdays minValue=0 maxValue=23 step=1
            Setpoint item=vMorningTimeMinutesWeekdays minValue=0 maxValue=55 step=5
			Text icon="clock" label="Time of The Day" item=vTimeOfDay
			Text icon="clock" label="Sunrise" item=vSunrise_Time
			Text icon="clock" label="Sunset" item=vSunset_Time
			Text icon="clock" label="Evening" item=vEvening_Time
			Text icon="clock" label="Day Of The Week" item=vDayOfWeek
			Text icon="clock" label="Morning on Weekdays" item=vMorningWeekdays
			
		}
			
	}

But the problem is to get my rule working that I can assign the time to the item vMorningWeekdays as DateTime itemType.

For debugging purposes I also tried to assign as string to vTimeOfDay, but then I have problems with leading zeros :frowning:

rule "Calculate morning time"
when
	Item vMorningTimeHoursWeekdays changed or
	Item vMorningTimeMinutesWeekdays changed 
then
	//var DateTime morningTime = parse(now.getYear() + "-" + now.getMonthOfYear() + "-" + now.getDayOfMonth() + "T" +vMorningTimeHoursWeekdays.state +":" + vMorningTimeMinutesWeekdays.state)
	//vMorningWeekdays.sendCommand(morningTime)
	//vMorningWeekdays.sendCommand(String::format("%02d:%02d", vMorningTimeHoursWeekdays.state , vMorningTimeMinutesWeekdays.state ))
	vTimeOfDay.sendCommand(String::format("%02d:%02d", vMorningTimeHoursWeekdays.state , vMorningTimeMinutesWeekdays.state ))
end

I got it finally to work, however it seems like an awful long rule for something really simple :frowning:

rule "Calculate morning time"
when
	Item vMorningTimeHoursWeekdays changed or
	Item vMorningTimeMinutesWeekdays changed 
then

	var String msg = ""
    
    // Copy the Alarm-Time from the UI to local variables
    var hour = vMorningTimeHoursWeekdays.state as DecimalType
    var minute = vMorningTimeMinutesWeekdays.state as DecimalType
  
    // Combine the hour and minutes to one string to be displayed in the 
    // user interface
    if (hour < 10) { msg = "0" } 
    msg = msg + hour.format("%d") + ":"
    
    if (minute < 10) { msg = msg + "0" }
    msg = msg + minute.format("%d")
    
	vMorningWeekdays.postUpdate(new DateTime(parse(now.getYear() + "-" + now.getMonthOfYear() + "-" + now.getDayOfMonth() + "T" +msg +":55.000-04:00")).toString)

end