forked from dileepbapat/faketime
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.java
More file actions
29 lines (21 loc) · 1.07 KB
/
Copy pathTest.java
File metadata and controls
29 lines (21 loc) · 1.07 KB
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
28
29
import java.util.Date;
public class Test {
public static void main(String[] args) throws Throwable {
System.out.println(System.getProperties());
java.lang.reflect.Method m = java.lang.ClassLoader.class.getDeclaredMethod("loadLibrary", Class.class, String.class, Boolean.TYPE);
m.setAccessible(true);
m.invoke(null, java.lang.System.class, "jvmfaketime", false);
System.out.println(System.currentTimeMillis());
System.out.println(new Date());
System.registerFakeCurrentTimeMillis();
System.out.println(System.currentTimeMillis());
System.out.println(new Date());
System.deregisterFakeCurrentTimeMillis();
System.out.println(System.currentTimeMillis());
System.out.println(new Date());
System.registerFakeCurrentTimeMillis();
System.out.println("offset " + System.getTimeOffset() + " " + new Date());
System.setTimeOffset(2000);
System.out.println("offset " + System.getTimeOffset() + " " + new Date());
}
}