diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-11-06 19:39:49 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-11-06 19:39:49 +1300 |
commit | 315c359711b37b1afd90117564332f0770033057 (patch) | |
tree | 1a0f0ba2902cacf96b90a42c1fcf34a64b0d995f /src/org/traccar/protocol/MxtProtocolDecoder.java | |
parent | 87a8c80f324ede8f8faa54800f286e18b969ffd1 (diff) | |
download | trackermap-server-315c359711b37b1afd90117564332f0770033057.tar.gz trackermap-server-315c359711b37b1afd90117564332f0770033057.tar.bz2 trackermap-server-315c359711b37b1afd90117564332f0770033057.zip |
Replace Calendar with DateBuilder
Diffstat (limited to 'src/org/traccar/protocol/MxtProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/MxtProtocolDecoder.java | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/src/org/traccar/protocol/MxtProtocolDecoder.java b/src/org/traccar/protocol/MxtProtocolDecoder.java index ba97694d3..dc1a95d32 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; @@ -64,12 +62,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 +71,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); |