diff options
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r-- | src/org/traccar/protocol/H02ProtocolEncoder.java | 14 | ||||
-rw-r--r-- | src/org/traccar/protocol/OsmAndProtocolDecoder.java | 7 | ||||
-rw-r--r-- | src/org/traccar/protocol/SmokeyProtocolDecoder.java | 9 |
3 files changed, 15 insertions, 15 deletions
diff --git a/src/org/traccar/protocol/H02ProtocolEncoder.java b/src/org/traccar/protocol/H02ProtocolEncoder.java index 87fad6016..6d5cfb298 100644 --- a/src/org/traccar/protocol/H02ProtocolEncoder.java +++ b/src/org/traccar/protocol/H02ProtocolEncoder.java @@ -16,19 +16,19 @@ */ package org.traccar.protocol; -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; import org.traccar.StringProtocolEncoder; import org.traccar.model.Command; +import java.util.Date; + public class H02ProtocolEncoder extends StringProtocolEncoder { private static final String MARKER = "HQ"; - private Object formatCommand(DateTime time, String uniqueId, String type, String... params) { + private Object formatCommand(Date time, String uniqueId, String type, String... params) { - StringBuilder result = new StringBuilder(String.format("*%s,%s,%s,%02d%02d%02d", - MARKER, uniqueId, type, time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute())); + StringBuilder result = new StringBuilder( + String.format("*%s,%s,%s,%4$tH%4$tM%4$tS", MARKER, uniqueId, type, time)); for (String param : params) { result.append(",").append(param); @@ -39,7 +39,7 @@ public class H02ProtocolEncoder extends StringProtocolEncoder { return result.toString(); } - protected Object encodeCommand(Command command, DateTime time) { + protected Object encodeCommand(Command command, Date time) { String uniqueId = getUniqueId(command.getDeviceId()); switch (command.getType()) { @@ -62,7 +62,7 @@ public class H02ProtocolEncoder extends StringProtocolEncoder { @Override protected Object encodeCommand(Command command) { - return encodeCommand(command, new DateTime(DateTimeZone.UTC)); + return encodeCommand(command, new Date()); } } diff --git a/src/org/traccar/protocol/OsmAndProtocolDecoder.java b/src/org/traccar/protocol/OsmAndProtocolDecoder.java index b270b6071..4d6a0d259 100644 --- a/src/org/traccar/protocol/OsmAndProtocolDecoder.java +++ b/src/org/traccar/protocol/OsmAndProtocolDecoder.java @@ -19,7 +19,6 @@ import io.netty.channel.Channel; import io.netty.handler.codec.http.FullHttpRequest; import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.handler.codec.http.QueryStringDecoder; -import org.joda.time.format.ISODateTimeFormat; import org.traccar.BaseHttpProtocolDecoder; import org.traccar.DeviceSession; import org.traccar.model.CellTower; @@ -31,6 +30,8 @@ import java.net.SocketAddress; import java.nio.charset.StandardCharsets; import java.text.DateFormat; import java.text.SimpleDateFormat; +import java.time.Instant; +import java.time.format.DateTimeFormatter; import java.util.Date; import java.util.List; import java.util.Map; @@ -81,8 +82,8 @@ public class OsmAndProtocolDecoder extends BaseHttpProtocolDecoder { position.setTime(new Date(timestamp)); } catch (NumberFormatException error) { if (value.contains("T")) { - position.setTime(new Date( - ISODateTimeFormat.dateTimeParser().parseMillis(value))); + position.setTime( + Date.from(Instant.from(DateTimeFormatter.ISO_DATE_TIME.parse(value)))); } else { DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); position.setTime(dateFormat.parse(value)); diff --git a/src/org/traccar/protocol/SmokeyProtocolDecoder.java b/src/org/traccar/protocol/SmokeyProtocolDecoder.java index 825108ed2..b9cef5ad4 100644 --- a/src/org/traccar/protocol/SmokeyProtocolDecoder.java +++ b/src/org/traccar/protocol/SmokeyProtocolDecoder.java @@ -19,9 +19,6 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufUtil; import io.netty.buffer.Unpooled; import io.netty.channel.Channel; -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; -import org.joda.time.Seconds; import org.traccar.BaseProtocolDecoder; import org.traccar.DeviceSession; import org.traccar.NetworkMessage; @@ -33,6 +30,8 @@ import org.traccar.model.WifiAccessPoint; import java.net.SocketAddress; import java.nio.charset.StandardCharsets; +import java.time.Instant; +import java.time.temporal.ChronoUnit; public class SmokeyProtocolDecoder extends BaseProtocolDecoder { @@ -52,8 +51,8 @@ public class SmokeyProtocolDecoder extends BaseProtocolDecoder { response.writeByte(3); // protocol version response.writeByte(MSG_DATE_RECORD_ACK); response.writeBytes(id); - response.writeInt(Seconds.secondsBetween( - new DateTime(2000, 1, 1, 0, 0, DateTimeZone.UTC), new DateTime(DateTimeZone.UTC)).getSeconds()); + response.writeInt( + (int) ChronoUnit.SECONDS.between(Instant.parse("2000-01-01T00:00:00.00Z"), Instant.now())); response.writeByte(index); response.writeByte(report - 0x200); |