We have a module which streams alarm, tag history, and audit events to Kafka. For example on an alarm event we would send the timestamp like this:
String json = new JSONObject()
.put("uuid", alarm.getId().toString())
.put("gatewayName", this.hostName)
.put("provider", provider)
.put("tagPath", tagPath)
.put("displayPath", path)
.put("priority", alarm.getPriority().ordinal())
.put("eventType", alarm.getState().ordinal())
.put("eventData", String.valueOf(data.getRawValueMap()))
.put("eventFlags", alarm.getLastEventState().ordinal())
.put("epochms", data.getTimestamp())
.toString();
SinkData toSend = new SinkData(alarmTopic, json, alarmSinkName);
sendKafkaData(toSend, false);
For “epochms” when this reaches Kafka, we can see it is the local timestamp, but since we have many locations in different time zones we want to unify to UTC.
Of course we can write a simple function to do the conversion, but I am wondering if there is some global setting we can set such that wherever we call “getTimestamp” it always returns the UTC time in millis.
Thanks,
Nick