diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 698898f..dc0ff23 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,10 +2,7 @@ - - - @@ -112,7 +109,7 @@ - + @@ -122,7 +119,7 @@ - + @@ -162,7 +159,7 @@ - + @@ -203,8 +200,8 @@ - - + + @@ -216,7 +213,7 @@ - + @@ -750,8 +747,8 @@ @@ -1566,7 +1563,7 @@ - + @@ -1574,7 +1571,7 @@ - + @@ -1582,7 +1579,7 @@ - + @@ -1611,15 +1608,15 @@ - + - - + + diff --git a/src/main/java/com/henrypump/poc/Database.java b/src/main/java/com/henrypump/poc/Database.java index 1e63d9c..66f5c3d 100644 --- a/src/main/java/com/henrypump/poc/Database.java +++ b/src/main/java/com/henrypump/poc/Database.java @@ -17,6 +17,7 @@ import org.bson.Document; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; +import java.time.ZoneId; import java.time.ZonedDateTime; import com.mongodb.client.MongoCursor; @@ -139,10 +140,11 @@ public class Database { public long newMeasurement(Measurement inpMeasurement){ - ZonedDateTime nowDate = ZonedDateTime.now(); - ZonedDateTime todayDate = ZonedDateTime.of(nowDate.getYear(), nowDate.getMonthValue(), nowDate.getDayOfMonth(), 0, 0, 0, 0, nowDate.getZone()); + ZonedDateTime nowDate = ZonedDateTime.now(ZoneId.of("UTC")); + ZonedDateTime todayDate = ZonedDateTime.of(nowDate.getYear(), nowDate.getMonthValue(), nowDate.getDayOfMonth(), 0, 0, 0, 0, ZoneId.of("UTC")); Date storeDate = Date.from(todayDate.toInstant()); Document nowMeasurement = new Document("values." + nowDate.getHour() + "." + nowDate.getMinute(), inpMeasurement.getCurrentValue()) + .append("currentValue", inpMeasurement.getCurrentValue()) .append("maxValue", inpMeasurement.getDailyMax()) .append("minValue", inpMeasurement.getDailyMin()) .append("averageValue", inpMeasurement.getAverage())