aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/protocol/OsmAndProtocolDecoder.java10
-rw-r--r--test/org/traccar/protocol/OsmAndProtocolDecoderTest.java5
2 files changed, 12 insertions, 3 deletions
diff --git a/src/org/traccar/protocol/OsmAndProtocolDecoder.java b/src/org/traccar/protocol/OsmAndProtocolDecoder.java
index f2810c461..e732c6631 100644
--- a/src/org/traccar/protocol/OsmAndProtocolDecoder.java
+++ b/src/org/traccar/protocol/OsmAndProtocolDecoder.java
@@ -30,6 +30,7 @@ import org.jboss.netty.handler.codec.http.HttpResponse;
import org.jboss.netty.handler.codec.http.HttpResponseStatus;
import org.jboss.netty.handler.codec.http.HttpVersion;
import org.jboss.netty.handler.codec.http.QueryStringDecoder;
+import org.joda.time.format.ISODateTimeFormat;
import org.traccar.BaseProtocolDecoder;
import org.traccar.model.Event;
import org.traccar.model.Position;
@@ -78,8 +79,13 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder {
}
position.setTime(new Date(timestamp));
} catch (NumberFormatException error) {
- DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- position.setTime(dateFormat.parse(value));
+ if (value.contains("T")) {
+ position.setTime(new Date(
+ ISODateTimeFormat.dateTimeParser().parseMillis(value)));
+ } else {
+ DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ position.setTime(dateFormat.parse(value));
+ }
}
break;
case "lat":
diff --git a/test/org/traccar/protocol/OsmAndProtocolDecoderTest.java b/test/org/traccar/protocol/OsmAndProtocolDecoderTest.java
index 6f895265d..d035ba7ef 100644
--- a/test/org/traccar/protocol/OsmAndProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/OsmAndProtocolDecoderTest.java
@@ -9,7 +9,10 @@ public class OsmAndProtocolDecoderTest extends ProtocolTest {
public void testDecode() throws Exception {
OsmAndProtocolDecoder decoder = new OsmAndProtocolDecoder(new OsmAndProtocol());
-
+
+ verifyPosition(decoder, request(
+ "/?id=902064&lat=42.06288&lon=-88.23412&timestamp=2016-01-27T18%3A55%3A47Z&hdop=6.0&altitude=224.0&speed=0.0"));
+
verifyPosition(decoder, request(
"/?id=902064&lat=42.06288&lon=-88.23412&timestamp=1442068686579&hdop=6.0&altitude=224.0&speed=0.0"));