aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-09-17 15:50:19 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2018-09-17 15:50:19 +1200
commit7e2ed343d2a6a03938c3f074417464c63d31fd59 (patch)
tree61dd514f7618ac07b56ccfd84f607e3d8b7c4b98 /src/org
parentda5286acb0c81f5b9bfe92eaa30e9759e3fff6b5 (diff)
downloadtrackermap-server-7e2ed343d2a6a03938c3f074417464c63d31fd59.tar.gz
trackermap-server-7e2ed343d2a6a03938c3f074417464c63d31fd59.tar.bz2
trackermap-server-7e2ed343d2a6a03938c3f074417464c63d31fd59.zip
Remove joda time library
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/database/StatisticsManager.java4
-rw-r--r--src/org/traccar/helper/DateUtil.java10
-rw-r--r--src/org/traccar/protocol/H02ProtocolEncoder.java14
-rw-r--r--src/org/traccar/protocol/OsmAndProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/SmokeyProtocolDecoder.java9
-rw-r--r--src/org/traccar/web/CsvBuilder.java8
-rw-r--r--src/org/traccar/web/GpxBuilder.java9
-rw-r--r--src/org/traccar/web/WebServer.java1
8 files changed, 26 insertions, 36 deletions
diff --git a/src/org/traccar/database/StatisticsManager.java b/src/org/traccar/database/StatisticsManager.java
index dcf15bb04..c2011a878 100644
--- a/src/org/traccar/database/StatisticsManager.java
+++ b/src/org/traccar/database/StatisticsManager.java
@@ -15,7 +15,6 @@
*/
package org.traccar.database;
-import org.joda.time.format.ISODateTimeFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.traccar.Context;
@@ -24,6 +23,7 @@ import org.traccar.model.Statistics;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Form;
import java.sql.SQLException;
+import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
@@ -72,7 +72,7 @@ public class StatisticsManager {
String url = Context.getConfig().getString("server.statistics");
if (url != null) {
- String time = ISODateTimeFormat.dateTime().print(statistics.getCaptureTime().getTime());
+ String time = DateTimeFormatter.ISO_DATE_TIME.format(statistics.getCaptureTime().toInstant());
Form form = new Form();
form.param("version", Context.getAppVersion());
diff --git a/src/org/traccar/helper/DateUtil.java b/src/org/traccar/helper/DateUtil.java
index 30bb1b2fa..458c74609 100644
--- a/src/org/traccar/helper/DateUtil.java
+++ b/src/org/traccar/helper/DateUtil.java
@@ -15,16 +15,13 @@
*/
package org.traccar.helper;
+import java.time.Instant;
+import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.Date;
-import org.joda.time.format.DateTimeFormatter;
-import org.joda.time.format.ISODateTimeFormat;
-
public final class DateUtil {
- private static final DateTimeFormatter DATE_FORMAT = ISODateTimeFormat.dateTimeParser();
-
private DateUtil() {
}
@@ -61,6 +58,7 @@ public final class DateUtil {
}
public static Date parseDate(String value) {
- return DATE_FORMAT.parseDateTime(value).toDate();
+ return Date.from(Instant.from(DateTimeFormatter.ISO_DATE_TIME.parse(value)));
}
+
}
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);
diff --git a/src/org/traccar/web/CsvBuilder.java b/src/org/traccar/web/CsvBuilder.java
index 29e2ccfbc..f7455b528 100644
--- a/src/org/traccar/web/CsvBuilder.java
+++ b/src/org/traccar/web/CsvBuilder.java
@@ -19,6 +19,7 @@ package org.traccar.web;
import java.beans.Introspector;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
@@ -28,9 +29,6 @@ import java.util.SortedSet;
import java.util.TreeSet;
import com.fasterxml.jackson.core.JsonProcessingException;
-import org.joda.time.DateTime;
-import org.joda.time.format.DateTimeFormatter;
-import org.joda.time.format.ISODateTimeFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.traccar.Context;
@@ -41,7 +39,6 @@ public class CsvBuilder {
private static final String LINE_ENDING = "\r\n";
private static final String SEPARATOR = ";";
- private static final DateTimeFormatter DATE_FORMAT = ISODateTimeFormat.dateTime();
private StringBuilder builder = new StringBuilder();
@@ -94,7 +91,7 @@ public class CsvBuilder {
addSeparator();
} else if (method.getReturnType().equals(Date.class)) {
Date value = (Date) method.invoke(object);
- builder.append(DATE_FORMAT.print(new DateTime(value)));
+ builder.append(DateTimeFormatter.ISO_DATE_TIME.format(value.toInstant()));
addSeparator();
} else if (method.getReturnType().equals(Map.class)) {
Map value = (Map) method.invoke(object);
@@ -163,4 +160,5 @@ public class CsvBuilder {
public String build() {
return builder.toString();
}
+
}
diff --git a/src/org/traccar/web/GpxBuilder.java b/src/org/traccar/web/GpxBuilder.java
index bac7182dc..a4daf154e 100644
--- a/src/org/traccar/web/GpxBuilder.java
+++ b/src/org/traccar/web/GpxBuilder.java
@@ -16,11 +16,8 @@
*/
package org.traccar.web;
+import java.time.format.DateTimeFormatter;
import java.util.Collection;
-
-import org.joda.time.DateTime;
-import org.joda.time.format.DateTimeFormatter;
-import org.joda.time.format.ISODateTimeFormat;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
@@ -41,8 +38,6 @@ public class GpxBuilder {
+ "</trkpt>%n";
private static final String FOOTER = "</trkseg></trk></gpx>";
- private static final DateTimeFormatter DATE_FORMAT = ISODateTimeFormat.dateTime();
-
public GpxBuilder() {
builder.append(HEADER);
builder.append("<trkseg>\n");
@@ -55,7 +50,7 @@ public class GpxBuilder {
public void addPosition(Position position) {
builder.append(String.format(POINT, position.getLatitude(), position.getLongitude(),
- DATE_FORMAT.print(new DateTime(position.getFixTime())), position.getAltitude(),
+ DateTimeFormatter.ISO_DATE_TIME.format(position.getFixTime().toInstant()), position.getAltitude(),
position.getCourse(), UnitsConverter.mpsFromKnots(position.getSpeed())));
}
diff --git a/src/org/traccar/web/WebServer.java b/src/org/traccar/web/WebServer.java
index 4bb88578f..90ea74a3b 100644
--- a/src/org/traccar/web/WebServer.java
+++ b/src/org/traccar/web/WebServer.java
@@ -130,7 +130,6 @@ public class WebServer {
resourceHandler.setResourceBase(config.getString("web.path"));
if (config.getBoolean("web.debug")) {
resourceHandler.setWelcomeFiles(new String[] {"debug.html", "index.html"});
- resourceHandler.setMinMemoryMappedContentLength(-1); // avoid locking files on Windows
} else {
String cache = config.getString("web.cacheControl");
if (cache != null && !cache.isEmpty()) {