diff options
-rw-r--r-- | src/org/traccar/protocol/OwnTracksProtocolDecoder.java | 9 | ||||
-rw-r--r-- | test/org/traccar/protocol/OwnTracksProtocolDecoderTest.java | 4 |
2 files changed, 5 insertions, 8 deletions
diff --git a/src/org/traccar/protocol/OwnTracksProtocolDecoder.java b/src/org/traccar/protocol/OwnTracksProtocolDecoder.java index a5a9efbb4..f664d113b 100644 --- a/src/org/traccar/protocol/OwnTracksProtocolDecoder.java +++ b/src/org/traccar/protocol/OwnTracksProtocolDecoder.java @@ -1,6 +1,6 @@ /* * Copyright 2017 Jan-Piet Mens (jpmens@gmail.com) - * Copyright 2013 - 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2017 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,11 +87,7 @@ public class OwnTracksProtocolDecoder extends BaseProtocolDecoder { position.set("topic", root.getString("topic")); } - long timestamp = root.getJsonNumber("tst").longValue(); - if (timestamp < Integer.MAX_VALUE) { - timestamp *= 1000; - } - position.setTime(new Date(timestamp)); + position.setTime(new Date(root.getJsonNumber("tst").longValue() * 1000)); DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, root.getString("tid")); if (deviceSession == null) { @@ -103,4 +99,5 @@ public class OwnTracksProtocolDecoder extends BaseProtocolDecoder { sendResponse(channel, HttpResponseStatus.OK); return position; } + } diff --git a/test/org/traccar/protocol/OwnTracksProtocolDecoderTest.java b/test/org/traccar/protocol/OwnTracksProtocolDecoderTest.java index 1eb188421..75d9af041 100644 --- a/test/org/traccar/protocol/OwnTracksProtocolDecoderTest.java +++ b/test/org/traccar/protocol/OwnTracksProtocolDecoderTest.java @@ -12,10 +12,10 @@ public class OwnTracksProtocolDecoderTest extends ProtocolTest { OwnTracksProtocolDecoder decoder = new OwnTracksProtocolDecoder(new OwnTracksProtocol()); verifyPosition(decoder, request(HttpMethod.POST, "/", - buffer(text("{\"lon\":2.29513,\"lat\":48.85833,\"tst\":1497349316,\"_type\":\"location\",\"tid\":\"JJ\"}")))); + buffer("{\"lon\":2.29513,\"lat\":48.85833,\"tst\":1497349316,\"_type\":\"location\",\"tid\":\"JJ\"}"))); verifyPosition(decoder, request(HttpMethod.POST, "/", - buffer(text("{\"cog\":271,\"lon\":2.29513,\"acc\":5,\"vel\":61,\"vac\":21,\"lat\":48.85833,\"tst\":1497349316,\"alt\":167,\"_type\":\"location\",\"tid\":\"JJ\",\"t\":\"u\",\"batt\":67}")))); + buffer("{\"cog\":271,\"lon\":2.29513,\"acc\":5,\"vel\":61,\"vac\":21,\"lat\":48.85833,\"tst\":1497349316,\"alt\":167,\"_type\":\"location\",\"tid\":\"JJ\",\"t\":\"u\",\"batt\":67}"))); } |