Deprecate joda-time
- ref:
http://blog.joda.org/2014/11/converting-from-joda-time-to-javatime.html
Change-Id: I1115e8053f601e78cb933ccbfa664ff8787d2da1
diff --git a/apps/influxdbmetrics/src/main/java/org/onosproject/influxdbmetrics/DefaultInfluxMetric.java b/apps/influxdbmetrics/src/main/java/org/onosproject/influxdbmetrics/DefaultInfluxMetric.java
index ab8f31c..f3ce81a 100644
--- a/apps/influxdbmetrics/src/main/java/org/onosproject/influxdbmetrics/DefaultInfluxMetric.java
+++ b/apps/influxdbmetrics/src/main/java/org/onosproject/influxdbmetrics/DefaultInfluxMetric.java
@@ -15,22 +15,20 @@
*/
package org.onosproject.influxdbmetrics;
-import org.apache.commons.lang.StringUtils;
-import org.joda.time.DateTime;
-import org.joda.time.format.DateTimeFormat;
-import org.joda.time.format.DateTimeFormatter;
-
import static com.google.common.base.Preconditions.checkNotNull;
+import java.time.Instant;
+import java.time.format.DateTimeFormatter;
+
/**
* Default implementation of influx metric.
*/
public final class DefaultInfluxMetric implements InfluxMetric {
private double oneMinRate;
- private DateTime time;
+ private Instant time;
- private DefaultInfluxMetric(double oneMinRate, DateTime time) {
+ private DefaultInfluxMetric(double oneMinRate, Instant time) {
this.oneMinRate = oneMinRate;
this.time = time;
}
@@ -41,7 +39,7 @@
}
@Override
- public DateTime time() {
+ public Instant time() {
return time;
}
@@ -75,10 +73,8 @@
return new DefaultInfluxMetric(oneMinRate, parseTime(timestamp));
}
- private DateTime parseTime(String time) {
- String reformatTime = StringUtils.replace(StringUtils.replace(time, "T", " "), "Z", "");
- DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
- return formatter.parseDateTime(reformatTime);
+ private Instant parseTime(String time) {
+ return DateTimeFormatter.ISO_DATE_TIME.parse(time, Instant::from);
}
}
}