Use guava's Stopwatch instead of custom one.

Bug: 163745065
Test: ./run-data-pipeline.sh finished successfully. Also I've run "atest ." in data_pipeline folder.

Change-Id: I7233eb119339a5ce9198a31f057067baa8381b82
diff --git a/data_pipeline/Android.bp b/data_pipeline/Android.bp
index ad61c9f..833d602 100644
--- a/data_pipeline/Android.bp
+++ b/data_pipeline/Android.bp
@@ -32,6 +32,7 @@
         "geotz_data_pipeline_protos",
         "geotz_geojson",
         "geotz_s2storage_tools_protos",
+        "guava",
         "libprotobuf-java-full",
         "s2-geometry-library-java",
         "tzids",
diff --git a/data_pipeline/src/main/java/com/android/timezone/geolocation/data_pipeline/steps/TzS2CellUnionsToTzS2Ranges.java b/data_pipeline/src/main/java/com/android/timezone/geolocation/data_pipeline/steps/TzS2CellUnionsToTzS2Ranges.java
index a789851..c8a62ee 100644
--- a/data_pipeline/src/main/java/com/android/timezone/geolocation/data_pipeline/steps/TzS2CellUnionsToTzS2Ranges.java
+++ b/data_pipeline/src/main/java/com/android/timezone/geolocation/data_pipeline/steps/TzS2CellUnionsToTzS2Ranges.java
@@ -24,7 +24,8 @@
 import com.android.timezone.geolocation.data_pipeline.steps.Types.TzS2Range;
 import com.android.timezone.geolocation.data_pipeline.steps.Types.TzS2Ranges;
 import com.android.timezone.geolocation.data_pipeline.util.NamedFuture;
-import com.android.timezone.geolocation.data_pipeline.util.StopWatch;
+
+import com.google.common.base.Stopwatch;
 import com.google.common.geometry.S2CellId;
 import com.google.common.geometry.S2CellUnion;
 
@@ -147,7 +148,7 @@
     }
 
     private static TzS2Ranges createTzS2Ranges(TzS2CellUnion tzS2CellUnion, int s2Level) {
-        StopWatch stopWatch = new StopWatch();
+        Stopwatch stopwatch = Stopwatch.createStarted();
 
         String tzId = tzS2CellUnion.tzId;
         List<String> tzIds = Collections.singletonList(tzId);
@@ -184,8 +185,8 @@
 
         // Sorting the ranges is not necessary. As the input is sorted , it will already be sorted.
 
-        System.out.println("Created " + ranges.size() + " S2Ranges for " + tzId
-                + " in " + stopWatch.reportElapsed() + "...");
+        System.out.printf("Created %s S2Ranges for %s in %s...\n",
+                ranges.size(), tzId, stopwatch.elapsed());
         return new TzS2Ranges(ranges);
     }
 
diff --git a/data_pipeline/src/main/java/com/android/timezone/geolocation/data_pipeline/steps/TzS2PolygonsToTzS2CellUnions.java b/data_pipeline/src/main/java/com/android/timezone/geolocation/data_pipeline/steps/TzS2PolygonsToTzS2CellUnions.java
index 5cc8b08..31ada14 100644
--- a/data_pipeline/src/main/java/com/android/timezone/geolocation/data_pipeline/steps/TzS2PolygonsToTzS2CellUnions.java
+++ b/data_pipeline/src/main/java/com/android/timezone/geolocation/data_pipeline/steps/TzS2PolygonsToTzS2CellUnions.java
@@ -23,7 +23,8 @@
 import com.android.timezone.geolocation.data_pipeline.steps.Types.TzS2CellUnion;
 import com.android.timezone.geolocation.data_pipeline.steps.Types.TzS2Polygons;
 import com.android.timezone.geolocation.data_pipeline.util.NamedFuture;
-import com.android.timezone.geolocation.data_pipeline.util.StopWatch;
+
+import com.google.common.base.Stopwatch;
 import com.google.common.geometry.S2CellId;
 import com.google.common.geometry.S2CellUnion;
 import com.google.common.geometry.S2Polygon;
@@ -148,7 +149,7 @@
     }
 
     private static TzS2CellUnion createTzS2CellUnion(TzS2Polygons tzPolygons, int maxS2Level) {
-        StopWatch stopWatch = new StopWatch();
+        Stopwatch stopwatch = Stopwatch.createStarted();
 
         S2RegionCoverer s2RegionCovererQuad = new S2RegionCoverer();
         s2RegionCovererQuad.setMinLevel(1);
@@ -169,10 +170,8 @@
         }
         S2CellUnion combinedCellUnion = new S2CellUnion();
         combinedCellUnion.initFromCellIds(cellIds);
-        System.out.println("Created S2CellUnion for " + tzId
-                + " containing " + cellIds.size() + " cells"
-                + " at level " + maxS2Level
-                + " in " + stopWatch.reportElapsed() + "...");
+        System.out.printf("Created S2CellUnion for %s containing %s cells at level %S in %s...\n",
+                tzId, cellIds.size(), maxS2Level, stopwatch.elapsed());
         return new TzS2CellUnion(tzId, combinedCellUnion);
     }
 }
diff --git a/data_pipeline/src/main/java/com/android/timezone/geolocation/data_pipeline/util/StopWatch.java b/data_pipeline/src/main/java/com/android/timezone/geolocation/data_pipeline/util/StopWatch.java
deleted file mode 100644
index 078bc5b..0000000
--- a/data_pipeline/src/main/java/com/android/timezone/geolocation/data_pipeline/util/StopWatch.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.timezone.geolocation.data_pipeline.util;
-
-/**
- * A basic class for tracking elapsed time of an operation.
- *
- * TODO Remove and migrate to Guava's StopWatch.
- */
-public final class StopWatch {
-
-    private final long mStartTimeMillis;
-
-    /** Creates (and starts) the stop watch. */
-    public StopWatch() {
-        mStartTimeMillis = System.currentTimeMillis();
-    }
-
-    /** Reports elapsed time since this instance was created. */
-    public String reportElapsed() {
-        long elapsedMillis = System.currentTimeMillis() - mStartTimeMillis;
-        if (elapsedMillis < 1000) {
-            return elapsedMillis + " millis";
-        }
-        return (elapsedMillis / 1000) + " seconds";
-    }
-}