Skip to content

Commit

Permalink
Handling cases in which the date is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
itaiag committed Jan 15, 2018
1 parent 1e192f9 commit 4ea1d22
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class DateTimeConverter {
private static final DateTimeFormatter ELASTICSEARCH_FORMATTER_SUFFIX = DateTimeFormatter
.ofPattern("yyyy/MM/dd HH:mm:ss:");

private static final DateTimeFormatter REVERSE_DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy/MM/dd");

private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("dd/MM/yyyy");

private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern("HH:mm:ss:SS");
Expand Down Expand Up @@ -96,6 +98,10 @@ public String toElasticString() {
public String toDateString() {
return date.toInstant().atZone(ZoneId.systemDefault()).format(DATE_FORMATTER);
}

public String toReverseDateString() {
return date.toInstant().atZone(ZoneId.systemDefault()).format(REVERSE_DATE_FORMATTER);
}

public String toTimeString() {
return date.toInstant().atZone(ZoneId.systemDefault()).format(TIME_FORMATTER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,10 @@ private List<ElasticsearchTest> convertToElasticTests(ExecutionMetadata metadata
private ElasticsearchTest testNodeToElasticTest(ExecutionMetadata metadata, MachineNode machineNode,
TestNode testNode) {
String timestamp = null;
if (testNode.getTimestamp() != null) {
if (testNode.getDate() != null && testNode.getTimestamp() != null) {
timestamp = testNode.getDate() + " " + testNode.getTimestamp();
} else if (null == testNode.getDate() && testNode.getTimestamp() !=null) {
timestamp = fromNowDateObject().toReverseDateString() + " " + testNode.getTimestamp();
} else {
timestamp = fromNowDateObject().toElasticString();
}
Expand Down

0 comments on commit 4ea1d22

Please sign in to comment.