aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-10-13 10:27:02 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-10-13 10:27:02 +1300
commit797263bfe9655ac82a97954c6930ec4a650a0609 (patch)
treef3d5605298763d9d20c44ee07fc2a312ee92d084 /src/org/traccar/protocol
parentf95de7fdb6f9a47618b30a991949b86567d6deb9 (diff)
downloadtraccar-server-797263bfe9655ac82a97954c6930ec4a650a0609.tar.gz
traccar-server-797263bfe9655ac82a97954c6930ec4a650a0609.tar.bz2
traccar-server-797263bfe9655ac82a97954c6930ec4a650a0609.zip
Create date builder util class
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/Gt06ProtocolDecoder.java15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
index 6f62baf11..5d79958a5 100644
--- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -24,6 +24,7 @@ import org.jboss.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.Context;
import org.traccar.helper.Checksum;
+import org.traccar.helper.DateBuilder;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Event;
import org.traccar.model.Position;
@@ -157,16 +158,10 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(getDeviceId());
position.setProtocol(getProtocolName());
- // Date and time
- Calendar time = Calendar.getInstance(timeZone);
- time.clear();
- time.set(Calendar.YEAR, 2000 + buf.readUnsignedByte());
- time.set(Calendar.MONTH, buf.readUnsignedByte() - 1);
- time.set(Calendar.DAY_OF_MONTH, buf.readUnsignedByte());
- time.set(Calendar.HOUR_OF_DAY, buf.readUnsignedByte());
- time.set(Calendar.MINUTE, buf.readUnsignedByte());
- time.set(Calendar.SECOND, buf.readUnsignedByte());
- position.setTime(time.getTime());
+ DateBuilder dateBuilder = new DateBuilder(timeZone)
+ .setDate(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte())
+ .setTime(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte());
+ position.setTime(dateBuilder.build());
// GPS length and Satellites count
int gpsLength = buf.readUnsignedByte();