From 6c5e1344ba73202170d3044db4bad71f1b5af700 Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Wed, 26 Mar 2014 20:05:26 +0100 Subject: [PATCH] Add a Utils.currentTimeSeconds method with a TODO to convert other usages over --- core/src/main/java/com/google/bitcoin/core/Utils.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/google/bitcoin/core/Utils.java b/core/src/main/java/com/google/bitcoin/core/Utils.java index b91a0981..bdb7f99a 100644 --- a/core/src/main/java/com/google/bitcoin/core/Utils.java +++ b/core/src/main/java/com/google/bitcoin/core/Utils.java @@ -482,14 +482,19 @@ public class Utils { return new Date(); } - /** Returns the current time in seconds since the epoch, or a mocked out equivalent. */ + // TODO: Replace usages of this where the result is / 1000 with currentTimeSeconds. + /** Returns the current time in milliseconds since the epoch, or a mocked out equivalent. */ public static long currentTimeMillis() { if (mockTime != null) return mockTime.getTime(); else return System.currentTimeMillis(); } - + + public static long currentTimeSeconds() { + return currentTimeMillis() / 1000; + } + public static byte[] copyOf(byte[] in, int length) { byte[] out = new byte[length]; System.arraycopy(in, 0, out, 0, Math.min(length, in.length));