forked from akulapid/jvmfaketime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tests.java
27 lines (24 loc) · 1023 Bytes
/
Tests.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import java.util.*;
import java.lang.reflect.Method;
import static java.lang.System.*;
public class Tests {
public static void main(String[] args) {
try {
Method m = ClassLoader.class.getDeclaredMethod("loadLibrary", Class.class, String.class, Boolean.TYPE);
m.setAccessible(true);
m.invoke(null, java.lang.System.class, "jvmfaketime", false);
} catch (Exception e) {
System.out.println("couldn't load native library.");
}
out.println("current time: " + new Date());
startFakingTime();
moveTimeBy(30 * 24 * 60 * 60 * 1000l);
out.println("faked by 30 days: " + new Date());
out.println("faked still, true time: " + new Date());
resetTime();
out.println("defaked: " + new Date());
startFakingTime();
moveTimeBy(1 * 24 * 60 * 60 * 1000l);
out.println("faked by 1 day again: " + new Date());
}
}