From ffc1755cca2476dc9a4bb430c968207657997222 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 4 Jun 2014 19:42:56 +1200 Subject: Support alternative time format --- src/org/traccar/protocol/OsmAndProtocolDecoder.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/OsmAndProtocolDecoder.java b/src/org/traccar/protocol/OsmAndProtocolDecoder.java index 5cb6e6455..560f3224f 100644 --- a/src/org/traccar/protocol/OsmAndProtocolDecoder.java +++ b/src/org/traccar/protocol/OsmAndProtocolDecoder.java @@ -16,6 +16,8 @@ package org.traccar.protocol; import java.nio.charset.Charset; +import java.text.DateFormat; +import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import java.util.Map; @@ -70,7 +72,12 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder { // Decode position position.setValid(true); if (params.containsKey("timestamp")) { - position.setTime(new Date(Long.valueOf(params.get("timestamp").get(0)) * 1000)); + try { + position.setTime(new Date(Long.valueOf(params.get("timestamp").get(0)) * 1000)); + } catch (NumberFormatException error) { + DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + position.setTime(dateFormat.parse(params.get("timestamp").get(0))); + } } else { position.setTime(new Date()); } -- cgit v1.2.3