From 209ad636006c21d9b45b2786f2eb4bcf7578e80c Mon Sep 17 00:00:00 2001 From: imtheuser <40696564+imtheuser@users.noreply.github.com> Date: Sun, 14 Oct 2018 11:30:00 +0200 Subject: [PATCH] Updated Section DateTime Item (#784) * Updated Section DateTime Item The program code suggested in the documentation in section "// Convert DateTimeType to Joda DateTime" did not work for me. @rkoshak proposed two options in this post: https://community.openhab.org/t/error-timeinmillis-is-not-a-member-of-java-time-zoneddatetime/53079/3 Both worked for me. I have therefore replaced the existing code with rlkoshak's two options. * Update rules-dsl.md Signed-off-by: Rudolf Allgaier --- configuration/rules-dsl.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configuration/rules-dsl.md b/configuration/rules-dsl.md index 34a37d2fb..ef1466ba9 100644 --- a/configuration/rules-dsl.md +++ b/configuration/rules-dsl.md @@ -442,7 +442,8 @@ val Number epoch = (MyDateTimeItem.state as DateTimeType).zonedDateTime.timeInMi val Number nowEpoch = now.millis // Convert DateTimeType to Joda DateTime -val joda = new DateTime((MyDateTimeItem.state as DateTimeType).zonedDateTime.timeInMillis) +val jodaVariantOne = new DateTime(MyDateTimeItem.state.toString) +val jodaVariantTwo = new DateTime((MyDateTimeItem.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli) // Convert Joda DateTime to DateTimeType val calendar = java.util.Calendar::getInstance