Skip to content

Commit

Permalink
Use Java 8 time
Browse files Browse the repository at this point in the history
  • Loading branch information
urbim committed Dec 19, 2017
1 parent 91711b0 commit 2375e02
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions core/src/main/java/com/kumuluz/ee/metrics/json/models/Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@

import com.kumuluz.ee.metrics.utils.ServiceConfigInfo;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import java.time.Instant;

/**
* Model used for exporting service metadata.
Expand All @@ -35,26 +32,22 @@
*/
public class Service {

private final TimeZone tz = TimeZone.getTimeZone("UTC");
private final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'");

private String timestamp;
private Instant timestamp;
private String environment;
private String name;
private String version;
private String instance;

public Service() {
df.setTimeZone(tz);
this.timestamp = df.format(new Date());
this.timestamp = Instant.now();
this.environment = ServiceConfigInfo.getInstance().getEnvironment();
this.name = ServiceConfigInfo.getInstance().getServiceName();
this.version = ServiceConfigInfo.getInstance().getServiceVersion();
this.instance = ServiceConfigInfo.getInstance().getInstanceId();
}

public String getTimestamp() {
return timestamp;
return timestamp.toString();
}

public String getEnvironment() {
Expand Down

0 comments on commit 2375e02

Please sign in to comment.