Skip to content

Commit

Permalink
Fix to data formatting error
Browse files Browse the repository at this point in the history
  • Loading branch information
msmygit committed Dec 12, 2023
1 parent d747cbb commit b77fbc2
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
import org.junit.jupiter.api.Test;
import java.nio.ByteBuffer;
import java.text.ParseException;
import java.time.Instant;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.time.temporal.ChronoUnit;

import static org.junit.jupiter.api.Assertions.*;
Expand Down Expand Up @@ -108,10 +108,12 @@ void format_ShouldFormatDateRangeToString() throws ParseException {

@Test
void parse_ShouldParseStringToDateRange() throws ParseException {
DateTimeFormatter df = (new DateTimeFormatterBuilder())
.appendInstant(3).toFormatter();
String formattedDateTime = ZonedDateTime.now()
.withZoneSameInstant(ZoneOffset.UTC)
.truncatedTo(ChronoUnit.MILLIS)
.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME);
.format(df);

// Enclose in single quotes as per the error message
String dateRangeLiteral = "'" + formattedDateTime + "'";
Expand Down

0 comments on commit b77fbc2

Please sign in to comment.