Use UTC time zone
This commit is contained in:
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user