diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-11-07 17:33:12 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-11-07 17:33:12 +1300 |
commit | 912e63f296c6e4b7ec6e56768b55904e461dd07c (patch) | |
tree | 785c651b3a7ba6cf2a47b8ba15c4e1fe7b69cb74 /src/org/traccar/protocol/AutoFonProtocolDecoder.java | |
parent | 08df8bea6809065f1d1e7d1298e2634d7427894b (diff) | |
download | trackermap-server-912e63f296c6e4b7ec6e56768b55904e461dd07c.tar.gz trackermap-server-912e63f296c6e4b7ec6e56768b55904e461dd07c.tar.bz2 trackermap-server-912e63f296c6e4b7ec6e56768b55904e461dd07c.zip |
Replace Calendar with DateBuilder
Diffstat (limited to 'src/org/traccar/protocol/AutoFonProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/AutoFonProtocolDecoder.java | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/org/traccar/protocol/AutoFonProtocolDecoder.java b/src/org/traccar/protocol/AutoFonProtocolDecoder.java index c0c3aaf08..9356e2cd7 100644 --- a/src/org/traccar/protocol/AutoFonProtocolDecoder.java +++ b/src/org/traccar/protocol/AutoFonProtocolDecoder.java @@ -16,14 +16,13 @@ package org.traccar.protocol; import java.net.SocketAddress; -import java.util.Calendar; import java.util.LinkedList; import java.util.List; -import java.util.TimeZone; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; +import org.traccar.helper.DateBuilder; import org.traccar.model.Event; import org.traccar.model.Position; @@ -79,15 +78,10 @@ public class AutoFonProtocolDecoder extends BaseProtocolDecoder { position.setValid((valid & 0xc0) != 0); position.set(Event.KEY_SATELLITES, valid & 0x3f); - Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC")); - time.clear(); - time.set(Calendar.DAY_OF_MONTH, buf.readUnsignedByte()); - time.set(Calendar.MONTH, buf.readUnsignedByte() - 1); - time.set(Calendar.YEAR, 2000 + 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() + .setDateReverse(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte()) + .setTime(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte()); + position.setTime(dateBuilder.getDate()); position.setLatitude(convertCoordinate(buf.readInt())); position.setLongitude(convertCoordinate(buf.readInt())); @@ -120,7 +114,6 @@ public class AutoFonProtocolDecoder extends BaseProtocolDecoder { return null; } - // Send response if (channel != null) { channel.write(ChannelBuffers.wrappedBuffer(new byte[] {buf.readByte()})); } |