aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/utils/StopWatch.java
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/utils/StopWatch.java')
-rw-r--r--main/src/cgeo/geocaching/utils/StopWatch.java38
1 files changed, 38 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/utils/StopWatch.java b/main/src/cgeo/geocaching/utils/StopWatch.java
new file mode 100644
index 0000000..bd53e14
--- /dev/null
+++ b/main/src/cgeo/geocaching/utils/StopWatch.java
@@ -0,0 +1,38 @@
+/**
+*
+*/
+package cgeo.geocaching.utils;
+
+
+/**
+ * Stop watch
+ *
+ * @author blafoo
+ */
+public final class StopWatch {
+
+ private long start;
+
+ public StopWatch() {
+ reset();
+ }
+
+ public void reset() {
+ start = System.currentTimeMillis();
+ }
+
+ /**
+ * @return difference in ms from the start to "now"
+ */
+ public String getTimeAsString() {
+ return String.format("%d ms", getTime());
+ }
+
+ /**
+ * @return difference in ms from the start to "now"
+ */
+ public long getTime() {
+ return System.currentTimeMillis() - start;
+ }
+
+} \ No newline at end of file