Skip to content

Commit

Permalink
GitHub action test run fix attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
zubri committed Jan 8, 2025
1 parent 5223de0 commit 5f16317
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,28 @@

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.*;

import org.junit.jupiter.api.Test;

class OffsetDateTimeAdapterTest {

@Test
void testOffsetDateTime() throws Exception {
ZoneId zoneId = ZoneOffset.ofHours(-3);
ZoneId zoneId = ZoneId.systemDefault();
ZoneOffset zoneOffset = zoneId.getRules().getStandardOffset(Instant.now());
String offset = zoneOffset.toString();
if (offset.equals("Z")) {
offset = "+00:00";
}

OffsetDateTime dateTime = LocalDateTime.parse("2021-09-19T12:13:14")
.atZone(zoneId)
.withEarlierOffsetAtOverlap()
.withFixedOffsetZone()
.withEarlierOffsetAtOverlap()
.toOffsetDateTime();

String offset = "-03:00";

// DateTime without offset and with/without fractional seconds
testDateTimeImpl("2021-09-19T12:13:14", "2021-09-19T12:13:14" + offset);
testDateTimeImpl("2021-09-19T12:13:14.1", "2021-09-19T12:13:14.1" + offset);
Expand Down Expand Up @@ -88,4 +90,8 @@ public void testOffsetDateTimeWithNanosOnlyZero() throws Exception {
testDateTimeImpl("2018-01-15T17:30:33.123456789Z", "2018-01-15T17:30:33.123456789+00:00");
testDateTimeImpl("2018-01-15T17:30:33Z", "2018-01-15T17:30:33+00:00");
}

private static String systemOffset() {
return offset;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,7 @@ public void testMarshallNoOffset() throws Exception {

@Test
public void testOffsetTime() throws Exception {
ZoneOffset zoneOffset = ZoneId.systemDefault().getRules().getStandardOffset(Instant.now());
String offset = zoneOffset.toString();
if (offset.equals("Z")) {
offset = "+00:00";
}
String offset = systemOffset();

// DateTime without offset and with/without fractional seconds
testTimeImpl("12:13:14", "12:13:14" + offset);
Expand Down Expand Up @@ -149,4 +145,13 @@ public void testOffsetTimeWithNanosOnlyZero() throws Exception {
testTimeImpl("17:30:33.123456789Z", "17:30:33.123456789+00:00");
testTimeImpl("17:30:33Z", "17:30:33+00:00");
}

private static String systemOffset() {
ZoneOffset zoneOffset = ZoneId.systemDefault().getRules().getStandardOffset(Instant.now());
String offset = zoneOffset.toString();
if (offset.equals("Z")) {
offset = "+00:00";
}
return offset;
}
}

0 comments on commit 5f16317

Please sign in to comment.