Skip to content

Commit a2b54a6

Browse files
isidorebrianberzinsLarsEckart
committed
t fix flakey test
Co-Authored-By: brianberzins <[email protected]> Co-Authored-By: Lars Eckart <[email protected]>
1 parent dc7126e commit a2b54a6

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

approvaltests-util-tests/src/test/java/com/spun/util/DateUtilsTest.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import java.util.Calendar;
1313
import java.util.Date;
1414
import java.util.GregorianCalendar;
15+
16+
import org.approvaltests.utils.WithTimeZone;
1517
import org.junit.jupiter.api.Test;
1618

1719
public class DateUtilsTest
@@ -21,9 +23,11 @@ public class DateUtilsTest
2123
@Test
2224
public void testToDate()
2325
{
24-
LocalDateTime time = LocalDateTime.of(2000, Month.JANUARY, 2, 3, 4, 5);
25-
assertEquals("2 Jan 2000 03:04:05 GMT", DateUtils.toDateInUTC(time).toGMTString());
26-
assertEquals("2 Jan 2000 02:04:05 GMT", DateUtils.toDate(time, ZoneOffset.ofHours(1)).toGMTString());
26+
try(WithTimeZone i = new WithTimeZone()) {
27+
LocalDateTime time = LocalDateTime.of(2000, Month.JANUARY, 2, 3, 4, 5);
28+
assertEquals("2 Jan 2000 03:04:05 GMT", DateUtils.toDateInUTC(time).toGMTString());
29+
assertEquals("2 Jan 2000 02:04:05 GMT", DateUtils.toDate(time, ZoneOffset.ofHours(1)).toGMTString());
30+
}
2731
}
2832
@Test
2933
public void testStartAndEndUseCases()

0 commit comments

Comments
 (0)