Skip to content

Commit

Permalink
Timestamp formatter update
Browse files Browse the repository at this point in the history
  • Loading branch information
mwodahl committed Apr 8, 2024
1 parent aa6c3d6 commit 9a7624b
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ private DateTimeUtils() {
}

public static String now() {
return nowZDT().format(DateTimeFormatter.ISO_INSTANT);
return nowZDT().format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"));
}

public static ZonedDateTime nowZDT() {
return ZonedDateTime.now(ZoneId.of("UTC"));
}

public static String isoDateTime(ZonedDateTime zonedDateTime) {
return zonedDateTime.format(DateTimeFormatter.ISO_INSTANT);
return zonedDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"));
}

public static ZonedDateTime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.junit.jupiter.api.Test;

import junit.framework.TestCase;
import us.dot.its.jpo.ode.util.DateTimeUtils;

public class DateTimeUtilsTest extends TestCase {

Expand All @@ -38,7 +37,7 @@ public void testIsoDateTime() throws ParseException {
expectedDate.getHour(),
expectedDate.getMinute(),
expectedDate.getSecond(),
expectedDate.getNano()/1000000).format(DateTimeFormatter.ISO_INSTANT);
expectedDate.getNano()/1000000).format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"));

assertEquals(sExpectedDate.substring(0, 18), sdate.substring(0, 18));
ZonedDateTime date2 = DateTimeUtils.isoDateTime("2015-11-30T16:06:15.679Z");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void run() {

// Set BSM Metadata values that can be assumed from the UDP endpoint
ZonedDateTime utc = ZonedDateTime.now(ZoneOffset.UTC);
String timestamp = utc.format(DateTimeFormatter.ISO_INSTANT);
String timestamp = utc.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"));
bsmMetadata.setOdeReceivedAt(timestamp);

ReceivedMessageDetails receivedMessageDetails = new ReceivedMessageDetails();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void run() {

// Add header data for the decoding process
ZonedDateTime utc = ZonedDateTime.now(ZoneOffset.UTC);
String timestamp = utc.format(DateTimeFormatter.ISO_INSTANT);
String timestamp = utc.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"));
mapMetadata.setOdeReceivedAt(timestamp);

mapMetadata.setOriginIp(senderIp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void run() {

// Add header data for the decoding process
ZonedDateTime utc = ZonedDateTime.now(ZoneOffset.UTC);
String timestamp = utc.format(DateTimeFormatter.ISO_INSTANT);
String timestamp = utc.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"));
psmMetadata.setOdeReceivedAt(timestamp);

psmMetadata.setOriginIp(senderIp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void run() {

// Add header data for the decoding process
ZonedDateTime utc = ZonedDateTime.now(ZoneOffset.UTC);
String timestamp = utc.format(DateTimeFormatter.ISO_INSTANT);
String timestamp = utc.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"));
spatMetadata.setOdeReceivedAt(timestamp);

spatMetadata.setOriginIp(senderIp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void run() {

// Add header data for the decoding process
ZonedDateTime utc = ZonedDateTime.now(ZoneOffset.UTC);
String timestamp = utc.format(DateTimeFormatter.ISO_INSTANT);
String timestamp = utc.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"));
srmMetadata.setOdeReceivedAt(timestamp);

srmMetadata.setOriginIp(senderIp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void run() {

// Add header data for the decoding process
ZonedDateTime utc = ZonedDateTime.now(ZoneOffset.UTC);
String timestamp = utc.format(DateTimeFormatter.ISO_INSTANT);
String timestamp = utc.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"));
ssmMetadata.setOdeReceivedAt(timestamp);

ssmMetadata.setOriginIp(senderIp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void run() {

// Add header data for the decoding process
ZonedDateTime utc = ZonedDateTime.now(ZoneOffset.UTC);
String timestamp = utc.format(DateTimeFormatter.ISO_INSTANT);
String timestamp = utc.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"));
timMetadata.setOdeReceivedAt(timestamp);

timMetadata.setOriginIp(senderIp);
Expand Down

0 comments on commit 9a7624b

Please sign in to comment.