|
9 | 9 | import java.time.LocalDateTime; |
10 | 10 | import java.time.Month; |
11 | 11 | import java.time.ZoneOffset; |
12 | | -import java.util.*; |
| 12 | +import java.util.Calendar; |
| 13 | +import java.util.Date; |
| 14 | +import java.util.GregorianCalendar; |
| 15 | +import java.util.TimeZone; |
13 | 16 |
|
14 | 17 | import static org.junit.jupiter.api.Assertions.assertEquals; |
15 | 18 | import static org.junit.jupiter.api.Assertions.assertTrue; |
@@ -58,14 +61,17 @@ private void assertStartAndEnd(StartAndEndUseCases useCase) |
58 | 61 | @Test |
59 | 62 | public void testNextAndLast() |
60 | 63 | { |
61 | | - int day = (new GregorianCalendar().get(Calendar.DAY_OF_WEEK) != Calendar.THURSDAY) |
62 | | - ? Calendar.THURSDAY |
63 | | - : Calendar.TUESDAY; |
64 | | - Timestamp next = DateUtils.getNextOrCurrent(day); |
65 | | - Timestamp last = DateUtils.getLastOrCurrent(day); |
66 | | - assertEquals(day, DateUtils.asCalendar(next).get(Calendar.DAY_OF_WEEK), "next thrusday"); |
67 | | - assertEquals(day, DateUtils.asCalendar(last).get(Calendar.DAY_OF_WEEK), "last thrusday"); |
68 | | - assertTrue(next.after(last), "order for " + next + " after" + last); |
| 64 | + try (WithTimeZone tz = new WithTimeZone()) |
| 65 | + { |
| 66 | + int day = (new GregorianCalendar().get(Calendar.DAY_OF_WEEK) != Calendar.THURSDAY) |
| 67 | + ? Calendar.THURSDAY |
| 68 | + : Calendar.TUESDAY; |
| 69 | + Timestamp next = DateUtils.getNextOrCurrent(day); |
| 70 | + Timestamp last = DateUtils.getLastOrCurrent(day); |
| 71 | + assertEquals(day, DateUtils.asCalendar(next).get(Calendar.DAY_OF_WEEK), "next thursday"); |
| 72 | + assertEquals(day, DateUtils.asCalendar(last).get(Calendar.DAY_OF_WEEK), "last thursday"); |
| 73 | + assertTrue(next.after(last), "order for " + next + " after" + last); |
| 74 | + } |
69 | 75 | } |
70 | 76 | public static class StartAndEndUseCases |
71 | 77 | { |
|
0 commit comments