rule "System started"
logInfo(“file”, “**>>> system started”)
var DateTimeFormatter dtf = DateTimeFormatter::forPattern(“yyyyMMddHHmmss”)
It looks like the rule engine is catching an exception and eating it. The error message does not disclose the actual exception so I have no idea what the problem is. Would be better is the details of the exception were printed to the log.
Any ideas what is wrong with the line of code that creates the DateTimeFormatter ??
If you use the Designer for editing your rules, you will see that it complains about not being able to resolve DateTimeFormat (and that import org.eclipse.smarthome.core.library.types.* etc. are not required).
After a lot of my own head-scratching trying to work out the available objects for date and time, I had more success with the later Java built-in objects, than joda.
Thinking about it, I think this is the real issue here: In OH1 I introduced joda, because it provided convenient methods for time handling. Now in OH2, we are on Java8, which actually comes with a modified version of joda built-in (as java.time) - so many classes are now available twice and the rule engine probably has a hard time to find the one you actually mean to use.
I wonder if it is time to get rid of the joda lib and change the rule engine to use the java built-in classes instead?
The Designer e.g. does not complain anymore, if you use:
rule "System started"
logInfo("file", "**>>> system started")
val DateTimeFormatter dtf = DateTimeFormatter::ofPattern("yyyyMMddHHmmss")
Although I don’t have the Java knowledge to comment on the relative strengths of the two libraries, from a user perspective having one unambiguous set of ‘standard’ objects to re-use would be a huge advantage over the confusion of many options in example code.
Copy/ Paste coding only got me so far before I had to start thinking!
The downside of rationalising out Joda is obviously that existing OH1 users would need to port across existing rule code and examples to Java8 / Xtend, but being able to refer to one set of known good documentation is really helpful. Even better if it comes for free via platform re-use…