We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docker run -it --name mytest -d registry.cn-shanghai.aliyuncs.com/lvgu/python3:latest jdk-8u251-linux-x64.tar.gz libfaketime master branch
package test;
import java.time.*; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit;
public class a { private static final int NO_DELAY = 0;
public static void main(String[] args) { Runnable printCurrentDateTime = () -> System.out.println(LocalDateTime.now());
Executors .newSingleThreadScheduledExecutor() .scheduleAtFixedRate(printCurrentDateTime, NO_DELAY, 1, TimeUnit.SECONDS);
} }
touch -t 0912241234.56 /app/my-demo-file.tmp
LD_PRELOAD=/usr/local/lib/faketime/libfaketime.so.1 \ FAKETIME='%' FAKETIME_FOLLOW_FILE=/app/my-demo-file.tmp \ FAKETIME_DONT_FAKE_MONOTONIC=1 \ FAKETIME_DONT_RESET=1 \ java -jar test.jar
2009-12-24T12:34:56.338 2009-12-24T12:34:57.308 2009-12-24T12:34:58.301 2009-12-24T12:34:59.301 2009-12-24T12:35:00.300 2009-12-24T12:35:01.300 2009-12-24T12:35:02.300 2009-12-24T12:35:03.300 2009-12-24T12:35:04.299 2009-12-24T12:35:05.328 2009-12-24T12:35:06.299
touch -t 2002290123.45 /app/my-demo-file.tmp
2009-12-24T12:35:07.298 2009-12-24T12:35:08.300 2009-12-24T12:35:09.299 2009-12-24T12:35:10.303 2009-12-24T12:35:11.301 2009-12-24T12:35:12.300 2009-12-24T12:35:13.299 2009-12-24T12:35:14.303 2009-12-24T12:35:15.301
The text was updated successfully, but these errors were encountered:
does it work outside docker?
Sorry, something went wrong.
No branches or pull requests
execution environment
docker run -it --name mytest -d registry.cn-shanghai.aliyuncs.com/lvgu/python3:latest
jdk-8u251-linux-x64.tar.gz
libfaketime master branch
test.jar code
package test;
import java.time.*;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
public class a {
private static final int NO_DELAY = 0;
public static void main(String[] args) {
Runnable printCurrentDateTime = () -> System.out.println(LocalDateTime.now());
}
}
create any file with December 24th, 2009, 12:34:56 as timestamp
touch -t 0912241234.56 /app/my-demo-file.tmp
run test.jar printing the current time
console output
2009-12-24T12:34:56.338
2009-12-24T12:34:57.308
2009-12-24T12:34:58.301
2009-12-24T12:34:59.301
2009-12-24T12:35:00.300
2009-12-24T12:35:01.300
2009-12-24T12:35:02.300
2009-12-24T12:35:03.300
2009-12-24T12:35:04.299
2009-12-24T12:35:05.328
2009-12-24T12:35:06.299
now, while the above is running, change the file's timestamp
touch -t 2002290123.45 /app/my-demo-file.tmp
console output
2009-12-24T12:35:07.298
2009-12-24T12:35:08.300
2009-12-24T12:35:09.299
2009-12-24T12:35:10.303
2009-12-24T12:35:11.301
2009-12-24T12:35:12.300
2009-12-24T12:35:13.299
2009-12-24T12:35:14.303
2009-12-24T12:35:15.301
The text was updated successfully, but these errors were encountered: