Well… I have added:
val startsAtDT = ZonedDateTime.parse(startsAt, DateTimeFormatter.ISO_OFFSET_DATE_TIME)
logInfo("TestDateConvert", "ZonedDateTime from String Formatted = {%1$td.%1$tm.%1$ty %1$tH:%1$tM}", startsAtDT)
But that doesn’t work either:
2022-12-29 09:44:24.341 [INFO ] [ab.core.model.script.TestDateConvert] - startsAt = 2022-12-29T23:00:00.000+01:00
2022-12-29 09:44:24.341 [INFO ] [ab.core.model.script.TestDateConvert] - total = 0.1155
2022-12-29 09:44:24.341 [INFO ] [ab.core.model.script.TestDateConvert] - ZonedDateTime from String Formatted = {%1$td.%1$tm.%1$ty %1$tH:%1$tM}
I have then added the format to the variable:
val startsAtDT = ZonedDateTime.parse(startsAt, DateTimeFormatter.ISO_OFFSET_DATE_TIME)
logInfo("TestDateConvert", "ZonedDateTime from String Formatted = {}", startsAtDT.format("%1$td.%1$tm.%1$ty %1$tH:%1$tM"))
Same issue as before, but now with java.time.ZonedDateTime.format(java.time.format.DateTimeFormatter):
2022-12-29 09:48:20.504 [INFO ] [ab.core.model.script.TestDateConvert] - startsAt = 2022-12-29T00:00:00.000+01:00
2022-12-29 09:48:20.504 [INFO ] [ab.core.model.script.TestDateConvert] - total = 0.0746
2022-12-29 09:48:20.506 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'power_price-2' failed: An error occurred during the script execution: Could not invoke method: java.time.ZonedDateTime.format(java.time.format.DateTimeFormatter) on instance: 2022-12-29T00:00+01:00 in power_price
Note that I did try every option mentioned here, but still couldn’t figure it out:
Regards,
Nika.