aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/Gl200ProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2012-06-20 21:49:08 +0400
committerAnton Tananaev <anton.tananaev@gmail.com>2012-06-20 21:49:08 +0400
commit15d13a99d3215a3208b2c44a07a29a7af9c13de3 (patch)
tree1d335cbaffd3573ead57071cdb58dfdebbb1893c /src/org/traccar/protocol/Gl200ProtocolDecoder.java
parent6532c4c2e6d0d5a00c6e80c90c171448970e78fa (diff)
downloadtrackermap-server-15d13a99d3215a3208b2c44a07a29a7af9c13de3.tar.gz
trackermap-server-15d13a99d3215a3208b2c44a07a29a7af9c13de3.tar.bz2
trackermap-server-15d13a99d3215a3208b2c44a07a29a7af9c13de3.zip
Proper Calendar usage
Diffstat (limited to 'src/org/traccar/protocol/Gl200ProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/Gl200ProtocolDecoder.java13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
index 9b3144fe8..506b55790 100644
--- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
@@ -16,14 +16,13 @@
package org.traccar.protocol;
import java.util.Calendar;
-import java.util.GregorianCalendar;
import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
-import org.traccar.model.DataManager;
import org.traccar.GenericProtocolDecoder;
+import org.traccar.model.DataManager;
import org.traccar.model.Position;
/**
@@ -68,7 +67,7 @@ public class Gl200ProtocolDecoder extends GenericProtocolDecoder {
throws Exception {
String sentence = (String) msg;
-
+
// Parse message
Matcher parser = pattern.matcher(sentence);
if (!parser.matches()) {
@@ -83,19 +82,19 @@ public class Gl200ProtocolDecoder extends GenericProtocolDecoder {
// Get device by IMEI
String imei = parser.group(index++);
position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
-
+
// Validity
position.setValid(Integer.valueOf(parser.group(index++)) == 0 ? false : true);
-
+
// Position info
position.setSpeed(Double.valueOf(parser.group(index++)));
position.setCourse(Double.valueOf(parser.group(index++)));
position.setAltitude(Double.valueOf(parser.group(index++)));
position.setLongitude(Double.valueOf(parser.group(index++)));
position.setLatitude(Double.valueOf(parser.group(index++)));
-
+
// Date
- Calendar time = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
+ Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
time.clear();
time.set(Calendar.YEAR, Integer.valueOf(parser.group(index++)));
time.set(Calendar.MONTH, Integer.valueOf(parser.group(index++)) - 1);