From b5aa84f094b04ce17fb12fb42f5b904345094ca5 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 20 Aug 2013 20:29:58 +1200 Subject: Ignore invalid data --- src/org/traccar/protocol/TotemProtocolDecoder.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/org/traccar') 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 -- cgit v1.2.3