diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-10-13 10:34:02 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-10-13 10:34:02 +1300 |
commit | e997c2642b35350241614acaef6d606e37223fe6 (patch) | |
tree | 145cd9817c3b8d4954200ada5012b91719697f8f /src/org/traccar/protocol/GoSafeProtocolDecoder.java | |
parent | 797263bfe9655ac82a97954c6930ec4a650a0609 (diff) | |
download | trackermap-server-e997c2642b35350241614acaef6d606e37223fe6.tar.gz trackermap-server-e997c2642b35350241614acaef6d606e37223fe6.tar.bz2 trackermap-server-e997c2642b35350241614acaef6d606e37223fe6.zip |
Extend date builder interface
Diffstat (limited to 'src/org/traccar/protocol/GoSafeProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/GoSafeProtocolDecoder.java | 16 |
1 files changed, 5 insertions, 11 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; |