Hi, need some help here might be an obvious error but now pulling out my hairs to find out what is the problem.
In my rules I’d like to compare two dates both in string format “yyyy-MM-dd”, however I can’t seem to get it work. Below is my code:
var String currentDate = new DateTimeType().format("%1$tY-%1$tm-%1$td")
logInfo("NordPool", "Current date is {}", currentDate)
logInfo("NordPool", "API date is {}", CurrentApiDate.state)
if (currentDate == CurrentApiDate.state){
//The raw data is for today
logInfo("NordPool", "The raw data is for today")
}
else {
logInfo("NordPool", "The raw data is for tomorrow")
}```
Logs:
2022-11-07 11:50:05.774 [INFO ] [g.openhab.core.model.script.NordPool] - Current date is 2022-11-07
2022-11-07 11:50:05.775 [INFO ] [g.openhab.core.model.script.NordPool] - API date is 2022-11-07
2022-11-07 11:50:05.776 [INFO ] [g.openhab.core.model.script.NordPool] - The raw data is for tomorrow```
I have tried to use state.toString and equals method same result. I doubt checked the length of the strings they’re the same. Any suggestion?