DateTimeService { public Date getCurrentJavaDateTime() { return new DateTime().toDate(); }  Date getCurrentJavaDateTime(); void setCurrentDateTime(DateTime someDateTime); void resetToCurrentSystemDateTime(); DateTime getCurrentDateTime(); void setCurrentDateTimeFixed(DateTime dateTime); java.sql.Date getCurrentJavaSqlDate(); DateMidnight getCurrentDateMidnight();  }
@Test public void testGetCurrentJavaDateTime() { DateTimeService dateTimeService = new DateTimeService(); DateTime systemDateTime = new DateTime(System.currentTimeMillis()); DateTime timeServiceDateTime = new DateTime(dateTimeService.getCurrentJavaDateTime()); Duration duration = new Duration(systemDateTime,timeServiceDateTime); Assert.assertTrue("Expected the java date time returned by DateTimeService to be equal or close to the actual system time", duration.getMillis() < ONE_SECOND); }