aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/protocol/TotemProtocolDecoder.java10
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