diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2013-08-20 20:29:58 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2013-08-20 20:29:58 +1200 |
commit | b5aa84f094b04ce17fb12fb42f5b904345094ca5 (patch) | |
tree | b04c2056c00d3496300c2b41117244e956673dfb /src/org/traccar | |
parent | 4aa19cf3ab240abb7dc9c16240d993f5b525edaa (diff) | |
download | trackermap-server-b5aa84f094b04ce17fb12fb42f5b904345094ca5.tar.gz trackermap-server-b5aa84f094b04ce17fb12fb42f5b904345094ca5.tar.bz2 trackermap-server-b5aa84f094b04ce17fb12fb42f5b904345094ca5.zip |
Ignore invalid data
Diffstat (limited to 'src/org/traccar')
-rw-r--r-- | src/org/traccar/protocol/TotemProtocolDecoder.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/TotemProtocolDecoder.java b/src/org/traccar/protocol/TotemProtocolDecoder.java index 9ba4d7458..b4fa177be 100644 --- a/src/org/traccar/protocol/TotemProtocolDecoder.java +++ b/src/org/traccar/protocol/TotemProtocolDecoder.java @@ -123,8 +123,10 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { // Time Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC")); time.clear(); + int year = 0; if (!first) { - time.set(Calendar.YEAR, 2000 + Integer.valueOf(parser.group(index++))); + year = Integer.valueOf(parser.group(index++)); + time.set(Calendar.YEAR, 2000 + year); time.set(Calendar.MONTH, Integer.valueOf(parser.group(index++)) - 1); time.set(Calendar.DAY_OF_MONTH, Integer.valueOf(parser.group(index++))); } @@ -165,10 +167,14 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { // Date if (first) { - time.set(Calendar.YEAR, 2000 + Integer.valueOf(parser.group(index++))); + year = Integer.valueOf(parser.group(index++)); + time.set(Calendar.YEAR, 2000 + year); time.set(Calendar.MONTH, Integer.valueOf(parser.group(index++)) - 1); time.set(Calendar.DAY_OF_MONTH, Integer.valueOf(parser.group(index++))); } + if (year == 0) { + return null; // ignore invalid data + } position.setTime(time.getTime()); // Altitude |