diff options
Diffstat (limited to 'src/org/traccar/protocol/MxtProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/MxtProtocolDecoder.java | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/src/org/traccar/protocol/MxtProtocolDecoder.java b/src/org/traccar/protocol/MxtProtocolDecoder.java index ba97694d3..3ff127d5d 100644 --- a/src/org/traccar/protocol/MxtProtocolDecoder.java +++ b/src/org/traccar/protocol/MxtProtocolDecoder.java @@ -16,13 +16,11 @@ package org.traccar.protocol; import java.net.SocketAddress; -import java.util.Calendar; -import java.util.Date; -import java.util.TimeZone; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.BitUtil; +import org.traccar.helper.DateBuilder; import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; @@ -39,8 +37,7 @@ public class MxtProtocolDecoder extends BaseProtocolDecoder { @Override protected Object decode( - Channel channel, SocketAddress remoteAddress, Object msg) - throws Exception { + Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { ChannelBuffer buf = (ChannelBuffer) msg; @@ -64,12 +61,7 @@ public class MxtProtocolDecoder extends BaseProtocolDecoder { position.set(Event.KEY_INDEX, buf.readUnsignedShort()); - // Date and time - Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC")); - time.clear(); - time.set(Calendar.YEAR, 2000); - time.set(Calendar.MONTH, 0); - time.set(Calendar.DAY_OF_MONTH, 1); + DateBuilder dateBuilder = new DateBuilder().setDate(2000, 1, 1); long date = buf.readUnsignedInt(); @@ -78,12 +70,10 @@ public class MxtProtocolDecoder extends BaseProtocolDecoder { long minutes = BitUtil.between(date, 6, 6 + 6); long seconds = BitUtil.to(date, 6); - long millis = time.getTimeInMillis(); - millis += (((days * 24 + hours) * 60 + minutes) * 60 + seconds) * 1000; + dateBuilder.addMillis((((days * 24 + hours) * 60 + minutes) * 60 + seconds) * 1000); - position.setTime(new Date(millis)); + position.setTime(dateBuilder.getDate()); - // Location position.setValid(true); position.setLatitude(buf.readInt() / 1000000.0); position.setLongitude(buf.readInt() / 1000000.0); |