3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-01-31 07:12:17 +00:00

Add a Utils.currentTimeSeconds method with a TODO to convert other usages over

This commit is contained in:
Mike Hearn 2014-03-26 20:05:26 +01:00
parent a31010b379
commit 6c5e1344ba

View File

@ -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));