Skip to content

Commit

Permalink
Switched to DateTimeFormatter
Browse files Browse the repository at this point in the history
  • Loading branch information
jwomeara committed Mar 17, 2023
1 parent 5af9ff5 commit 9055715
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import datawave.security.authorization.DatawaveUser;
import datawave.security.authorization.SubjectIssuerDNPair;
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -46,8 +45,11 @@

import java.io.File;
import java.io.IOException;
import java.sql.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -106,6 +108,9 @@ public class AuditReplayTest {

private static Boolean isHealthy = Boolean.TRUE;

private static DateTimeFormatter dateTimeFormatter = new DateTimeFormatterBuilder().appendPattern("yyyy-MM-dd'T'HH:mm:ss.SSS").parseLenient()
.appendOffset("+HH:MM", "Z").toFormatter();

@BeforeAll
public static void classSetup() {
// create a temp dir for each test
Expand Down Expand Up @@ -2720,7 +2725,7 @@ private static Status mapToStatus(Map<String,Object> map) throws ParseException
status.setState(Status.ReplayState.valueOf((String) map.get("state")));
status.setPathUri((String) map.get("pathUri"));
status.setSendRate(Integer.toUnsignedLong((int) map.get("sendRate")));
status.setLastUpdated(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS").parse((String) map.get("lastUpdated")));
status.setLastUpdated(Date.from(ZonedDateTime.parse((String) map.get("lastUpdated"), dateTimeFormatter).toInstant()));
status.setReplayUnfinishedFiles((boolean) map.get("replayUnfinishedFiles"));

if (map.get("files") != null) {
Expand Down

0 comments on commit 9055715

Please sign in to comment.