From df253d4b0d61e72997a0fbbfe9b3cf6435840873 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janne=20L=C3=B6fhjelm?= Date: Thu, 15 Dec 2022 15:45:34 +0200 Subject: [PATCH 1/9] Migrate to vessels-v2/status API --- .../digitraffic/model/VesselsStatus.java | 24 ++++--------------- .../provider/MqttVesselLocationProvider.java | 2 +- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/model/VesselsStatus.java b/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/model/VesselsStatus.java index c95dbd4..354ec9a 100644 --- a/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/model/VesselsStatus.java +++ b/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/model/VesselsStatus.java @@ -9,26 +9,15 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class VesselsStatus { - public final int readErrors; - public final int sentErrors; public final ZonedDateTime updateTime; - public final String status; @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - public VesselsStatus(@JsonProperty("readErrors") int readErrors, - @JsonProperty("sentErrors") int sentErrors, - @JsonProperty("updateTime") ZonedDateTime updateTime, - @JsonProperty("status") String status) { - this.readErrors = readErrors; - this.sentErrors = sentErrors; + public VesselsStatus(@JsonProperty("updated") ZonedDateTime updateTime) { this.updateTime = updateTime; - this.status = status; } public boolean everythingOk() { - return 0 == readErrors && - 0 == sentErrors && - "CONNECTED".equals(status); + return updateTime != null; } @Override @@ -36,21 +25,18 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; VesselsStatus that = (VesselsStatus) o; - return readErrors == that.readErrors && sentErrors == that.sentErrors && Objects.equals(updateTime, that.updateTime) && Objects.equals(status, that.status); + return Objects.equals(updateTime, that.updateTime); } @Override public int hashCode() { - return Objects.hash(readErrors, sentErrors, updateTime, status); + return updateTime != null ? updateTime.hashCode() : 0; } @Override public String toString() { return "VesselsStatus{" + - "readErrors=" + readErrors + - ", sentErrors=" + sentErrors + - ", updateTime=" + updateTime + - ", status='" + status + '\'' + + "updateTime=" + updateTime + '}'; } } diff --git a/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/provider/MqttVesselLocationProvider.java b/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/provider/MqttVesselLocationProvider.java index f7fbc3e..211454f 100644 --- a/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/provider/MqttVesselLocationProvider.java +++ b/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/provider/MqttVesselLocationProvider.java @@ -76,7 +76,7 @@ public void connectComplete(boolean reconnect, String serverURI) { try { mqttAsyncClient.subscribe(topics, qos).waitForCompletion(); - mqttAsyncClient.subscribe("vessels/status", 0).waitForCompletion(); + mqttAsyncClient.subscribe("vessels-v2/status", 0).waitForCompletion(); } catch (MqttException e) { LOG.error("Failed to subscribe MQTT topics {} with QoS {}", topics, qos); onConnectionFailed.accept(e); From c060676f600343ff025cfc728519317bf958b8e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janne=20L=C3=B6fhjelm?= Date: Thu, 19 Jan 2023 10:16:07 +0200 Subject: [PATCH 2/9] Migrate to api v2 --- .../digitraffic/model/VesselLocation.java | 135 +++++++----------- 1 file changed, 50 insertions(+), 85 deletions(-) diff --git a/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/model/VesselLocation.java b/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/model/VesselLocation.java index c67aa50..78bb95e 100644 --- a/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/model/VesselLocation.java +++ b/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/model/VesselLocation.java @@ -13,15 +13,37 @@ public class VesselLocation implements VehiclePosition { public final Integer mmsi; public final LatLng coordinates; - public final Properties properties; + public final Double speed; //Speed over ground in knots + public final Double course; //Course over ground in degrees from north + public final Integer status; //Status + public final Double rateOfTurn; //Rate of turn + public final Boolean positionAccurate; + public final Boolean raim; + public final Double heading; //Heading of the vessel + public final Long timestamp; @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - public VesselLocation(@JsonProperty("mmsi") Integer mmsi, - @JsonProperty("geometry") @JsonDeserialize(using = LatLng.LatLngDeserializer.class) LatLng coordinates, - @JsonProperty("properties") Properties properties) { - this.mmsi = mmsi; - this.coordinates = coordinates; - this.properties = properties; + public VesselLocation(@JsonProperty("sog") Double speed, + @JsonProperty("cog") Double course, + @JsonProperty("navStat") Integer status, + @JsonProperty("rot") Double rateOfTurn, + @JsonProperty("posAcc") Boolean positionAccurate, + @JsonProperty("raim") Boolean raim, + @JsonProperty("heading") Double heading, + @JsonProperty("time") Long timestamp, + @JsonProperty("lat") Double latitude, + @JsonProperty("lon") Double longitude) { + this.mmsi = null; // TODO: Generate this. + this.speed = speed; + this.course = course; + this.status = status; + this.rateOfTurn = rateOfTurn; + this.positionAccurate = positionAccurate; + this.raim = raim; + this.heading = heading; + this.timestamp = timestamp; + + this.coordinates = new LatLng(latitude, longitude); } @Override @@ -31,12 +53,19 @@ public boolean equals(Object o) { VesselLocation that = (VesselLocation) o; return Objects.equals(mmsi, that.mmsi) && Objects.equals(coordinates, that.coordinates) && - Objects.equals(properties, that.properties); + Objects.equals(speed, that.speed) && + Objects.equals(course, that.course) && + Objects.equals(status, that.status) && + Objects.equals(rateOfTurn, that.rateOfTurn) && + Objects.equals(positionAccurate, that.positionAccurate) && + Objects.equals(raim, that.raim) && + Objects.equals(heading, that.heading) && + Objects.equals(timestamp, that.timestamp); } @Override public int hashCode() { - return Objects.hash(mmsi, coordinates, properties); + return Objects.hash(mmsi, coordinates, speed, course, status, rateOfTurn, positionAccurate, raim, heading, timestamp); } @Override @@ -44,7 +73,14 @@ public String toString() { return "VesselLocation{" + "mmsi=" + mmsi + ", coordinates=" + coordinates + - ", properties=" + properties + + ", speed=" + speed + + ", course=" + course + + ", status=" + status + + ", rateOfTurn=" + rateOfTurn + + ", positionAccurate=" + positionAccurate + + ", raim=" + raim + + ", heading=" + heading + + ", timestamp=" + timestamp + '}'; } @@ -55,93 +91,22 @@ public String getId() { @Override public LatLng getCoordinates() { - return new LatLng(coordinates.getLatitude(), coordinates.getLongitude()); + return new LatLng(coordinates.getLatitude(), coordinates.getLongitude()); //TODO: Is this "new" really necessary? } @Override public double getSpeed() { - return SpeedUtils.knotsToMetresPerSecond(properties.speed); + return SpeedUtils.knotsToMetresPerSecond(speed); } @Override public double getHeading() { //If vessel heading is not available (special value 511), use vessel course for heading - return Math.round(properties.heading) == 511 ? properties.course : properties.heading; + return Math.round(heading) == 511 ? course : heading; } @Override public long getTimestamp() { - return properties.timestamp; - } - - @JsonIgnoreProperties(value = { "timestamp" }, ignoreUnknown = true) - public static class Properties { - //Speed over ground in knots - public final Double speed; - //Course over ground in degrees from north - public final Double course; - //Status - public final Integer status; - //Rate of turn - public final Double rateOfTurn; - public final Boolean positionAccurate; - public final Boolean raim; - //Heading of the vessel - public final Double heading; - //Timestamp in milliseconds - public final Long timestamp; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - public Properties(@JsonProperty("sog") Double speed, - @JsonProperty("cog") Double course, - @JsonProperty("navStat") Integer status, - @JsonProperty("rot") Double rateOfTurn, - @JsonProperty("posAcc") Boolean positionAccurate, - @JsonProperty("raim") Boolean raim, - @JsonProperty("heading") Double heading, - @JsonProperty("timestampExternal") Long timestamp) { - this.speed = speed; - this.course = course; - this.status = status; - this.rateOfTurn = rateOfTurn; - this.positionAccurate = positionAccurate; - this.raim = raim; - this.heading = heading; - this.timestamp = timestamp; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Properties that = (Properties) o; - return Objects.equals(speed, that.speed) && - Objects.equals(course, that.course) && - Objects.equals(status, that.status) && - Objects.equals(rateOfTurn, that.rateOfTurn) && - Objects.equals(positionAccurate, that.positionAccurate) && - Objects.equals(raim, that.raim) && - Objects.equals(heading, that.heading) && - Objects.equals(timestamp, that.timestamp); - } - - @Override - public int hashCode() { - return Objects.hash(speed, course, status, rateOfTurn, positionAccurate, raim, heading, timestamp); - } - - @Override - public String toString() { - return "Properties{" + - "speed=" + speed + - ", course=" + course + - ", status=" + status + - ", rateOfTurn=" + rateOfTurn + - ", positionAccurate=" + positionAccurate + - ", raim=" + raim + - ", heading=" + heading + - ", timestamp=" + timestamp + - '}'; - } + return timestamp; } } From adead40f6cdbda8e2ad791db501b031d9219e8e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janne=20L=C3=B6fhjelm?= Date: Thu, 19 Jan 2023 10:22:54 +0200 Subject: [PATCH 3/9] Migrate to v2 --- .../digitraffic/model/VesselMetadata.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/model/VesselMetadata.java b/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/model/VesselMetadata.java index 8c20ef7..22685c9 100644 --- a/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/model/VesselMetadata.java +++ b/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/model/VesselMetadata.java @@ -25,13 +25,12 @@ public class VesselMetadata implements VehicleMetadata { public final String destination; @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - public VesselMetadata(@JsonProperty("mmsi") Integer mmsi, - @JsonProperty("name") String name, - @JsonProperty("shipType") Integer shipType, - @JsonProperty("referencePointA") Integer referencePointA, - @JsonProperty("referencePointB") Integer referencePointB, - @JsonProperty("referencePointC") Integer referencePointC, - @JsonProperty("referencePointD") Integer referencePointD, + public VesselMetadata(@JsonProperty("name") String name, + @JsonProperty("type") Integer shipType, + @JsonProperty("refA") Integer referencePointA, + @JsonProperty("refB") Integer referencePointB, + @JsonProperty("refC") Integer referencePointC, + @JsonProperty("refD") Integer referencePointD, @JsonProperty("posType") Integer positionType, @JsonProperty("draught") Integer draught, @JsonProperty("imo") Integer imo, @@ -39,7 +38,7 @@ public VesselMetadata(@JsonProperty("mmsi") Integer mmsi, @JsonProperty("eta") Long eta, @JsonProperty("timestamp") Long timestamp, @JsonProperty("destination") String destination) { - this.mmsi = mmsi; + this.mmsi = null; //TODO: Generate this. this.name = name; this.shipType = shipType; this.referencePointA = referencePointA; From 19c0ec7a9bb3377107460fc2874c86258e50df6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janne=20L=C3=B6fhjelm?= Date: Thu, 19 Jan 2023 10:24:10 +0200 Subject: [PATCH 4/9] Update topics for api v2 --- .../digitraffic/provider/MqttVesselLocationProvider.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/provider/MqttVesselLocationProvider.java b/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/provider/MqttVesselLocationProvider.java index 211454f..6980c14 100644 --- a/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/provider/MqttVesselLocationProvider.java +++ b/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/provider/MqttVesselLocationProvider.java @@ -70,7 +70,7 @@ public void start(Consumer locationConsumer, Consumer "vessels/" + mmsi + "/+/#").toArray(String[]::new); + String[] topics = mmsis.stream().map(mmsi -> "vessels-v2/" + mmsi + "/+/#").toArray(String[]::new); int[] qos = new int[topics.length]; Arrays.fill(qos, 0); @@ -99,7 +99,7 @@ public void messageArrived(String topic, MqttMessage message) { LOG.warn("Failed to parse vessel metadata", e); } } - if (topic.contains("locations")) { + if (topic.contains("location")) { try { locationConsumer.accept(objectMapper.readValue(message.getPayload(), VesselLocation.class)); } catch (IOException e) { From 932a760387e06c35e083bcd6e34b907bdc5ff263 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janne=20L=C3=B6fhjelm?= Date: Wed, 25 Jan 2023 10:34:51 +0200 Subject: [PATCH 5/9] Inject MMSI in messages --- .../digitraffic/model/VesselLocation.java | 4 ++-- .../digitraffic/model/VesselMetadata.java | 6 ++++- .../provider/MqttVesselLocationProvider.java | 24 ++++++++++++++++++- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/model/VesselLocation.java b/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/model/VesselLocation.java index 78bb95e..1c81bae 100644 --- a/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/model/VesselLocation.java +++ b/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/model/VesselLocation.java @@ -11,7 +11,8 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class VesselLocation implements VehiclePosition { - public final Integer mmsi; + @JacksonInject("mmsi") + public Integer mmsi; public final LatLng coordinates; public final Double speed; //Speed over ground in knots public final Double course; //Course over ground in degrees from north @@ -33,7 +34,6 @@ public VesselLocation(@JsonProperty("sog") Double speed, @JsonProperty("time") Long timestamp, @JsonProperty("lat") Double latitude, @JsonProperty("lon") Double longitude) { - this.mmsi = null; // TODO: Generate this. this.speed = speed; this.course = course; this.status = status; diff --git a/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/model/VesselMetadata.java b/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/model/VesselMetadata.java index 22685c9..76929a4 100644 --- a/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/model/VesselMetadata.java +++ b/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/model/VesselMetadata.java @@ -1,5 +1,6 @@ package fi.hsl.suomenlinna_hfp.digitraffic.model; +import com.fasterxml.jackson.annotation.JacksonInject; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; @@ -9,7 +10,10 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class VesselMetadata implements VehicleMetadata { - public final Integer mmsi; + + @JacksonInject("mmsi") + public Integer mmsi; + public final String name; public final Integer shipType; public final Integer referencePointA; diff --git a/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/provider/MqttVesselLocationProvider.java b/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/provider/MqttVesselLocationProvider.java index 6980c14..626c6ed 100644 --- a/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/provider/MqttVesselLocationProvider.java +++ b/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/provider/MqttVesselLocationProvider.java @@ -1,5 +1,6 @@ package fi.hsl.suomenlinna_hfp.digitraffic.provider; +import com.fasterxml.jackson.databind.InjectableValues; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import fi.hsl.suomenlinna_hfp.digitraffic.model.VesselLocation; @@ -14,6 +15,8 @@ import java.util.Collection; import java.util.concurrent.atomic.AtomicLong; import java.util.function.Consumer; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class MqttVesselLocationProvider extends VesselLocationProvider { private static final Logger LOG = LoggerFactory.getLogger(MqttVesselLocationProvider.class); @@ -94,16 +97,24 @@ public void connectionLost(Throwable cause) { public void messageArrived(String topic, MqttMessage message) { if (topic.contains("metadata")) { try { + injectMmsi(topic); + VesselMetadata vesselMetadata = objectMapper.readValue(message.getPayload(), VesselMetadata.class); metadataConsumer.accept(objectMapper.readValue(message.getPayload(), VesselMetadata.class)); } catch (IOException e) { LOG.warn("Failed to parse vessel metadata", e); + } finally { + objectMapper.setInjectableValues(new InjectableValues.Std()); } } if (topic.contains("location")) { try { - locationConsumer.accept(objectMapper.readValue(message.getPayload(), VesselLocation.class)); + injectMmsi(topic); + VesselLocation vesselLocation = objectMapper.readValue(message.getPayload(), VesselLocation.class); + locationConsumer.accept(vesselLocation); } catch (IOException e) { LOG.warn("Failed to parse vessel location", e); + } finally { + objectMapper.setInjectableValues(new InjectableValues.Std()); } } if (topic.contains("status")) { @@ -135,6 +146,17 @@ public void onFailure(IMqttToken asyncActionToken, Throwable exception) { }); } + private void injectMmsi(String topic) { + Pattern pattern = Pattern.compile("\\d{2,}"); + Matcher matcher = pattern.matcher(topic); + if (matcher.find()) { + String mmsi = matcher.group(); + InjectableValues injectableValues = new InjectableValues.Std().addValue("mmsi", Integer.parseInt(mmsi)); + objectMapper.setInjectableValues(injectableValues); + } + + } + @Override public long getLastReceivedTime() { return lastReceivedTime.get(); From d98ffb68f2ec166ca324e3a7b6c38fb8cf5ce5f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janne=20L=C3=B6fhjelm?= Date: Thu, 26 Jan 2023 09:48:11 +0200 Subject: [PATCH 6/9] Change timestamp to seconds --- src/main/java/fi/hsl/suomenlinna_hfp/hfp/utils/HfpUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/fi/hsl/suomenlinna_hfp/hfp/utils/HfpUtils.java b/src/main/java/fi/hsl/suomenlinna_hfp/hfp/utils/HfpUtils.java index ac09eff..51ab2f9 100644 --- a/src/main/java/fi/hsl/suomenlinna_hfp/hfp/utils/HfpUtils.java +++ b/src/main/java/fi/hsl/suomenlinna_hfp/hfp/utils/HfpUtils.java @@ -7,8 +7,8 @@ public class HfpUtils { private static final DateTimeFormatter TST_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSX"); - public static String formatTst(long timestampMillis) { - return TST_FORMATTER.format(Instant.ofEpochMilli(timestampMillis).atZone(ZoneId.of("UTC"))); + public static String formatTst(long timestampSeconds) { + return TST_FORMATTER.format(Instant.ofEpochSecond(timestampSeconds).atZone(ZoneId.of("UTC"))); } public static String formatStartTime(int seconds) { From 21ffb6f67ad8af673996bab00cf10f04e33bd447 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janne=20L=C3=B6fhjelm?= Date: Thu, 26 Jan 2023 13:14:33 +0200 Subject: [PATCH 7/9] Change injectMmsi to use split --- .../provider/MqttVesselLocationProvider.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/provider/MqttVesselLocationProvider.java b/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/provider/MqttVesselLocationProvider.java index 626c6ed..894b3c4 100644 --- a/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/provider/MqttVesselLocationProvider.java +++ b/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/provider/MqttVesselLocationProvider.java @@ -147,13 +147,9 @@ public void onFailure(IMqttToken asyncActionToken, Throwable exception) { } private void injectMmsi(String topic) { - Pattern pattern = Pattern.compile("\\d{2,}"); - Matcher matcher = pattern.matcher(topic); - if (matcher.find()) { - String mmsi = matcher.group(); - InjectableValues injectableValues = new InjectableValues.Std().addValue("mmsi", Integer.parseInt(mmsi)); - objectMapper.setInjectableValues(injectableValues); - } + String mmsi = topic.split("/")[1]; + InjectableValues injectableValues = new InjectableValues.Std().addValue("mmsi", Integer.parseInt(mmsi)); + objectMapper.setInjectableValues(injectableValues); } From 350716442d0c23751d20aa5d6fab052359318958 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janne=20L=C3=B6fhjelm?= Date: Thu, 26 Jan 2023 13:20:21 +0200 Subject: [PATCH 8/9] Fix timestamp --- .../hsl/suomenlinna_hfp/digitraffic/model/VesselLocation.java | 2 +- src/main/java/fi/hsl/suomenlinna_hfp/hfp/utils/HfpUtils.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/model/VesselLocation.java b/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/model/VesselLocation.java index 1c81bae..cf33e06 100644 --- a/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/model/VesselLocation.java +++ b/src/main/java/fi/hsl/suomenlinna_hfp/digitraffic/model/VesselLocation.java @@ -107,6 +107,6 @@ public double getHeading() { @Override public long getTimestamp() { - return timestamp; + return timestamp * 1000; } } diff --git a/src/main/java/fi/hsl/suomenlinna_hfp/hfp/utils/HfpUtils.java b/src/main/java/fi/hsl/suomenlinna_hfp/hfp/utils/HfpUtils.java index 51ab2f9..b32712f 100644 --- a/src/main/java/fi/hsl/suomenlinna_hfp/hfp/utils/HfpUtils.java +++ b/src/main/java/fi/hsl/suomenlinna_hfp/hfp/utils/HfpUtils.java @@ -8,7 +8,7 @@ public class HfpUtils { private static final DateTimeFormatter TST_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSX"); public static String formatTst(long timestampSeconds) { - return TST_FORMATTER.format(Instant.ofEpochSecond(timestampSeconds).atZone(ZoneId.of("UTC"))); + return TST_FORMATTER.format(Instant.ofEpochMilli(timestampSeconds).atZone(ZoneId.of("UTC"))); } public static String formatStartTime(int seconds) { From c3d182521d2c0206a51ee6fe54c0efc47b1bc17a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janne=20L=C3=B6fhjelm?= Date: Thu, 26 Jan 2023 13:22:49 +0200 Subject: [PATCH 9/9] Rename timeStampSeconds to timestampMillis --- src/main/java/fi/hsl/suomenlinna_hfp/hfp/utils/HfpUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/fi/hsl/suomenlinna_hfp/hfp/utils/HfpUtils.java b/src/main/java/fi/hsl/suomenlinna_hfp/hfp/utils/HfpUtils.java index b32712f..a7dc464 100644 --- a/src/main/java/fi/hsl/suomenlinna_hfp/hfp/utils/HfpUtils.java +++ b/src/main/java/fi/hsl/suomenlinna_hfp/hfp/utils/HfpUtils.java @@ -7,8 +7,8 @@ public class HfpUtils { private static final DateTimeFormatter TST_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSX"); - public static String formatTst(long timestampSeconds) { - return TST_FORMATTER.format(Instant.ofEpochMilli(timestampSeconds).atZone(ZoneId.of("UTC"))); + public static String formatTst(long timeStampMillis) { + return TST_FORMATTER.format(Instant.ofEpochMilli(timeStampMillis).atZone(ZoneId.of("UTC"))); } public static String formatStartTime(int seconds) {