aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/protocol/OsmAndProtocolDecoder.java6
-rw-r--r--test/org/traccar/protocol/OsmAndProtocolDecoderTest.java6
2 files changed, 9 insertions, 3 deletions
diff --git a/src/org/traccar/protocol/OsmAndProtocolDecoder.java b/src/org/traccar/protocol/OsmAndProtocolDecoder.java
index f89406a00..cf447c579 100644
--- a/src/org/traccar/protocol/OsmAndProtocolDecoder.java
+++ b/src/org/traccar/protocol/OsmAndProtocolDecoder.java
@@ -69,7 +69,11 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder {
position.setValid(true);
if (params.containsKey("timestamp")) {
try {
- position.setTime(new Date(Long.valueOf(params.get("timestamp").get(0)) * 1000));
+ long timestamp = Long.valueOf(params.get("timestamp").get(0));
+ if (timestamp < Integer.MAX_VALUE) {
+ timestamp *= 1000;
+ }
+ position.setTime(new Date(timestamp));
} catch (NumberFormatException error) {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
position.setTime(dateFormat.parse(params.get("timestamp").get(0)));
diff --git a/test/org/traccar/protocol/OsmAndProtocolDecoderTest.java b/test/org/traccar/protocol/OsmAndProtocolDecoderTest.java
index 62120d605..27fca29e7 100644
--- a/test/org/traccar/protocol/OsmAndProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/OsmAndProtocolDecoderTest.java
@@ -1,11 +1,10 @@
package org.traccar.protocol;
-import org.traccar.helper.TestIdentityManager;
import org.jboss.netty.handler.codec.http.DefaultHttpRequest;
import org.jboss.netty.handler.codec.http.HttpMethod;
import org.jboss.netty.handler.codec.http.HttpVersion;
-import static org.traccar.helper.DecoderVerifier.verify;
import org.junit.Test;
+import static org.traccar.helper.DecoderVerifier.verify;
public class OsmAndProtocolDecoderTest extends ProtocolDecoderTest {
@@ -15,6 +14,9 @@ public class OsmAndProtocolDecoderTest extends ProtocolDecoderTest {
OsmAndProtocolDecoder decoder = new OsmAndProtocolDecoder(new OsmAndProtocol());
verify(decoder.decode(null, null, new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET,
+ "/?id=902064&lat=42.06288&lon=-88.23412&timestamp=1442068686579&hdop=6.0&altitude=224.0&speed=0.0")));
+
+ verify(decoder.decode(null, null, new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET,
"/?lat=49.60688&lon=6.15788&timestamp=2014-06-04+09%3A10%3A11&altitude=384.7&speed=0.0&id=353861053849681")));
verify(decoder.decode(null, null, new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET,