I have an item
Number VU_Start "Start Sendung [%s]" ( VUPLUS ) { http="<[http://192.168.1.6:80/web/getcurrent:3000:XPATH(//e2currentserviceinformation/e2eventlist/e2event/e2eventstart)]" }
and want to use the received timestamp (epoch) e.g. 1514484000 (=Thursday, 28. December 2017 18:00:00 UTC)
as Date Time (actually as HH:mm)
I tried the example rules
// Convert epoch to a human readable
val SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
val String timestampString = sdf.format(new Date(timestampEpoch))
from here
but I failed I always get something like this: 1970-01-18T13:41:24.000+0100
my rule:
import java.text.SimpleDateFormat
import java.util.Date
/* Epoch */
rule "Dauer"
when
Item VU_Reference changed
then
val timestampEpoch = (VU_Start.state as Number).intValue
val SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
val String timestampString = sdf.format(new Date(timestampEpoch))
logWarn("hilfe", "Start Epoch " +timestampEpoch)
logWarn("hilfe", "Start " +timestampString)
end
The timestampEpoch gives me the correct number but the timestampString is wrong
any help appreciated!
thanks