Try using this method:
https://docs.oracle.com/javase/7/docs/api/java/util/Date.html#getTime()
Thanks, worked a treat
Unfortunately that didn't solve my problem though - maybe you can advise if there's a way around this?
The problem I have is repeated notifications for the same alarm.
The alarm in this case is powerCut
The powerCut alarm is computed by power < 1 ? "powerCut" : null
Notification for alarm powerCut
The reason is for example -
Tracker has no GSM signal and the power is disconnected, the tracker then records stores 1000 positions while it has no GSM and the power disconnected.
Power gets reconnected and the tracker moves to a location where it has GSM signal.
Tracker starts uploading the historic positions but because it is moving, is also uploading current positions.
The alarm state flicks between no alarm (current records) and powerCut (historic records)
50+ notifications get sent
I thought, ok I'll only trigger the alarm if there's less than 30 seconds different between the serverTime and the deviceTime like this:(power < 1) && (serverTime.getTime() - deviceTime.getTime() < 30000) ? "powerCut" : null
This fixes the above problem but creates another one...
Now if there's no power and the tracker goes through an area of no GSM signal, the stored records during this time turn the alarm off, but the current records will set it back to powerCut.
Advice would be appreciated.
Hi,
how can I subtract times in a computed attribute? I only want to trigger an alarm if
serverTime - deviceTime < 60 seconds
I'm guessing I need to convert them, but I've tried usual java time methods?
In other words ignore historic reports.
Thanks in advance
James