TimeContext { public static void clear() { setTime(null); setZone(null); } private  TimeContext(); static ZoneId getZone(); static long getMillis(); static Instant getTime(); static LocalDate getLocalDate(); static LocalDateTime getLocalDateTime(); static ZonedDateTime getZonedDateTime(); static void setTime(final Instant time); static void setNow(); static void setZone(final ZoneId zoneId); static void clear(); static void destroy();  }
@Test public void clear() throws Exception { assertNotNull(TimeContext.getLocalDateTime()); final Instant now = Instant.now(); TimeContext.setTime(now); assertEquals("The time should be equal", now, TimeContext.getLocalDateTime().atZone(TimeContext.getZone()).toInstant()); try { Thread.sleep(10L); } catch (InterruptedException ie) { } TimeContext.clear(); assertTrue(now.isBefore(TimeContext.getTime())); TimeContext.clear(); }