Date Time Format in OH2 Rules

I’ve been trying to format a time stamp in my notifications. I’ve tried using the same format I found from @hazymat in an OH1 rule:

But it is throwing an error and exiting the rule with out completion. Is there a new method in OH2 for formatting date/times in strings?

What exactly is the error?

@rtvb A not very helpful one from my perspective:

2017-01-19 20:08:26.292 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'Front Door Locked': An error occured during the script execution: null

How do I turn on debug for script execution to get a more detailed error log?

I also tried to set it up using JodaTime’s LocalTime() call but couldn’t even come close to figuring out how to pass formatting there (I’m 20 years removed from the last time I wrote code and it wasn’t in Java)

Could you show your rule please?

@danielwalters86 Sorry, was out of town.

Here it is. Using LocalTime it works fine so it seems it’s something in my use of formatting.

rule "Front Door Locked"
	Item Lock_GF_Living_LockButton received update
	var String NowTime = String::format( "%1$tl:%1$tM %1$tp", new Date() )
//	var DateTime NowTime = new LocalTime()
	if (Lock_GF_Living_LockButton.state == 1) {
		logInfo ("Front Door Lock","Locked" + NowTime)
		sendBroadcastNotification("Front door locked at " + NowTime)
		sendMail(mailTo, "Front Door Locked", "Door locked at " + NowTime)

I can’t see anything obvious when comparing your rule to the link you posted. However I haven’t checked whether it actually works but I’ll try it later tonight

Note: whenever I’ve used a date time in my rules I’ve used:

new DateTimeType()

Thanks @danielwalters86 I saw that floating around some other discussions as a native Java vs. using the Joda so will take a look