aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-10-13 10:34:02 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-10-13 10:34:02 +1300
commite997c2642b35350241614acaef6d606e37223fe6 (patch)
tree145cd9817c3b8d4954200ada5012b91719697f8f /src/org/traccar/protocol
parent797263bfe9655ac82a97954c6930ec4a650a0609 (diff)
downloadtrackermap-server-e997c2642b35350241614acaef6d606e37223fe6.tar.gz
trackermap-server-e997c2642b35350241614acaef6d606e37223fe6.tar.bz2
trackermap-server-e997c2642b35350241614acaef6d606e37223fe6.zip
Extend date builder interface
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/GoSafeProtocolDecoder.java16
-rw-r--r--src/org/traccar/protocol/Gt06ProtocolDecoder.java2
2 files changed, 6 insertions, 12 deletions
diff --git a/src/org/traccar/protocol/GoSafeProtocolDecoder.java b/src/org/traccar/protocol/GoSafeProtocolDecoder.java
index ad6a5a574..920f6dc36 100644
--- a/src/org/traccar/protocol/GoSafeProtocolDecoder.java
+++ b/src/org/traccar/protocol/GoSafeProtocolDecoder.java
@@ -16,16 +16,15 @@
package org.traccar.protocol;
import java.net.SocketAddress;
-import java.util.Calendar;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
-import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jboss.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.helper.BitUtil;
+import org.traccar.helper.DateBuilder;
import org.traccar.helper.PatternBuilder;
import org.traccar.model.Event;
import org.traccar.model.Position;
@@ -164,20 +163,15 @@ public class GoSafeProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
- time.clear();
- time.set(Calendar.HOUR_OF_DAY, Integer.parseInt(parser.group(index++)));
- time.set(Calendar.MINUTE, Integer.parseInt(parser.group(index++)));
- time.set(Calendar.SECOND, Integer.parseInt(parser.group(index++)));
- time.set(Calendar.DAY_OF_MONTH, Integer.parseInt(parser.group(index++)));
- time.set(Calendar.MONTH, Integer.parseInt(parser.group(index++)) - 1);
- time.set(Calendar.YEAR, 2000 + Integer.parseInt(parser.group(index++)));
+ DateBuilder dateBuilder = new DateBuilder()
+ .setTime(parser.group(index++), parser.group(index++), parser.group(index++))
+ .setDateReverse(parser.group(index++), parser.group(index++), parser.group(index++));
List<Position> positions = new LinkedList<>();
Matcher itemParser = PATTERN_ITEM.matcher(parser.group(index++));
while (itemParser.find()) {
- positions.add(decodePosition(itemParser, time.getTime()));
+ positions.add(decodePosition(itemParser, dateBuilder.getDate()));
}
return positions;
diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
index 5d79958a5..ffdbdf17b 100644
--- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -161,7 +161,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
DateBuilder dateBuilder = new DateBuilder(timeZone)
.setDate(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte())
.setTime(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte());
- position.setTime(dateBuilder.build());
+ position.setTime(dateBuilder.getDate());
// GPS length and Satellites count
int gpsLength = buf.readUnsignedByte();