DatabaseTimeLoader { public Date getDatabaseTime() { try (DatabaseContext dbCtx = new DatabaseContext(loginCredentials)) { ResultSet rs; Date result; rs = dbCtx.executeQuery("SELECT now() AS SystemTime"); result = readTimeField(rs); return result; } } DatabaseTimeLoader(DatabaseLoginCredentials loginCredentials); Date getDatabaseTime();  }
@Test public void testGetTime() { File authFile; Configuration config; DatabaseTimeLoader timeLoader; Date systemTime; Date databaseTime; long difference; authFile = dbUtils.getAuthorizationFile(); config = new Configuration(authFile); timeLoader = new DatabaseTimeLoader(config.getDatabaseLoginCredentials()); databaseTime = timeLoader.getDatabaseTime(); systemTime = new Date(); difference = databaseTime.getTime() - systemTime.getTime(); Assert.assertTrue("Database time is different to system time, databaseTime=" + databaseTime + ", systemTime=" + systemTime + ".", difference > -1000 && difference < 1000); }