# Force "getTimestamp" method to return UTC time

**URL:** <https://forum.inductiveautomation.com/t/force-gettimestamp-method-to-return-utc-time/59298>\
**Category:** Module Development\
**Created:** [May 6, 2022, 1:46pm UTC](https://forum.inductiveautomation.com/t/force-gettimestamp-method-to-return-utc-time/59298 "2022-05-06T13:46:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicholas.robinson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nicholas.robinson/32/22188_2.png) [@nicholas.robinson](https://forum.inductiveautomation.com/u/nicholas.robinson)\
**Post date:** [May 6, 2022, 1:46pm UTC](https://forum.inductiveautomation.com/t/force-gettimestamp-method-to-return-utc-time/59298/1 "2022-05-06T13:46:12Z")

</div>

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:

```auto
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

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [May 6, 2022, 1:58pm UTC](https://forum.inductiveautomation.com/t/force-gettimestamp-method-to-return-utc-time/59298/2 "2022-05-06T13:58:00Z")

</div>

They _are_ UTC, but as soon as you turn it into a Date to view it you see it in the local timezone running that code.

What kind of object is `data` in your code snippet?

---

<div class="post-metadata">

**Author:** ![nicholas.robinson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nicholas.robinson/32/22188_2.png) [@nicholas.robinson](https://forum.inductiveautomation.com/u/nicholas.robinson)\
**Post date:** [May 6, 2022, 2:11pm UTC](https://forum.inductiveautomation.com/t/force-gettimestamp-method-to-return-utc-time/59298/3 "2022-05-06T14:11:31Z")

</div>

Data in the alarm event is this:

```auto
public void sendEquipmentAlarm(AlarmEvent alarm, EventData data, KafkaSettingsRecord kafkaSettings)

```

Data in tag history is this:

```auto
public void storeData(HistoricalData data)

```

Data in audit events is this:

```auto
public void sendAuditData(AuditRecord record)

```

I do see what you are talking about. I made this record from a machine on eastern time:

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/4/44d386b48e433e6d806190298cde6591a17169e4.png)

Then if I look at that timestamp on a machine in EST it shows EST:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/0/d0eac266bc79d10f13bf6d53e7ffaea5dd1bf852.png)

If I look at the same timestamp in central time it shows central time:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/5/c5673c41e62f9291661cf24bcf852631bc8b5fb7.png)

So if I’m not mistaken here, if we want the millis timestamp to be in UTC,. there is nothing we need to do correct?

Thanks,

Nick

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [May 6, 2022, 2:12pm UTC](https://forum.inductiveautomation.com/t/force-gettimestamp-method-to-return-utc-time/59298/4 "2022-05-06T14:12:57Z")

</div>

> [@nicholas.robinson](#):
>
> So if I’m not mistaken here, if we want the millis timestamp to be in UTC,. there is nothing we need to do correct?

Yes, that's right.
