aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database/ObjectConverter.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/database/ObjectConverter.java')
-rw-r--r--src/org/traccar/database/ObjectConverter.java24
1 files changed, 3 insertions, 21 deletions
diff --git a/src/org/traccar/database/ObjectConverter.java b/src/org/traccar/database/ObjectConverter.java
index bd5b03064..4ab83faec 100644
--- a/src/org/traccar/database/ObjectConverter.java
+++ b/src/org/traccar/database/ObjectConverter.java
@@ -15,37 +15,19 @@
*/
package org.traccar.database;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
import java.util.Collection;
import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonArrayBuilder;
-import javax.json.JsonObjectBuilder;
-import org.traccar.model.Position;
public class ObjectConverter {
- private static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ssZ");
-
- public static JsonArray convert(Collection<Position> positions) {
+ public static JsonArray convert(Collection<? extends JsonConvertable> collection) {
JsonArrayBuilder array = Json.createArrayBuilder();
- for (Position position : positions) {
- JsonObjectBuilder object = Json.createObjectBuilder();
-
- //object.add("id", position.getId());
- object.add("time", dateFormat.format(position.getFixTime()));
- object.add("valid", position.getValid());
- object.add("latitude", position.getLatitude());
- object.add("longitude", position.getLongitude());
- object.add("altitude", position.getAltitude());
- object.add("speed", position.getSpeed());
- object.add("course", position.getCourse());
- //object.add("other", position.getExtendedInfo());
-
- array.add(object.build());
+ for (JsonConvertable object : collection) {
+ array.add(object.toJson());
}
return array.build();