Uses external MongoDB, uses dates instead of strings for timestamps
This commit is contained in:
@@ -2,7 +2,9 @@ package com.henrypump.poc;
|
||||
|
||||
import org.bson.Document;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
import static java.lang.Math.abs;
|
||||
|
||||
@@ -44,7 +46,9 @@ public class Measurement {
|
||||
|
||||
Document lastStored = this.db.getLastStoredMeasurement(this.tagName);
|
||||
try {
|
||||
ZonedDateTime timestamp = ZonedDateTime.parse((CharSequence) lastStored.get("timestamp"));
|
||||
Date lastStoredTimestamp = (Date) lastStored.get("timestamp");
|
||||
ZonedDateTime timestamp = ZonedDateTime.ofInstant(lastStoredTimestamp.toInstant(),
|
||||
ZoneId.systemDefault());
|
||||
if (isToday(timestamp)){
|
||||
this.average = lastStored.getDouble("dailyAverage");
|
||||
this.total = lastStored.getDouble("dailyTotal");
|
||||
|
||||
Reference in New Issue
Block a user