Use UTC time zone

This commit is contained in:
Patrick McDonagh
2017-04-13 18:08:47 -05:00
parent 9cfbda3c18
commit 33a027a458
2 changed files with 17 additions and 18 deletions

View File

@@ -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())