Use DateTimeUtils.currentTimeMillis() to get current time

This method from joda-time supports replacing the system time provider
with a custom provider for tests. Since it is verbose, and we expect
more related methods, put it in the more succinct TimeUtil.nowMs().

This commit covers the trivial cases in the server side; client-side
code still uses System.currentTimeMillis().

Change-Id: I6c56e8c5bbb0cf7b0271e431d1ebdb532967b9e8
This commit is contained in:
Dave Borowitz
2013-10-15 14:27:34 -07:00
parent 925bcc15e0
commit 46b1ac8f07
37 changed files with 152 additions and 64 deletions

View File

@@ -17,6 +17,8 @@ package com.google.gerrit.launcher;
import static java.util.concurrent.TimeUnit.DAYS;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import org.joda.time.DateTimeUtils;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
@@ -506,7 +508,7 @@ public final class GerritLauncher {
//
final File[] tmpEntries = tmp.listFiles();
if (tmpEntries != null) {
final long now = System.currentTimeMillis();
final long now = DateTimeUtils.currentTimeMillis();
final long expired = now - MILLISECONDS.convert(7, DAYS);
for (final File tmpEntry : tmpEntries) {
if (tmpEntry.isDirectory() && tmpEntry.lastModified() < expired) {