In my Java application, I use several libraries which invoke System.currentTimeMillis()
and Instant.now()
. These functions provide the current timestamp.
I would like to set the time of the application to something different than the real time.
E.g. 1 Jan 2023 16:00.
This will be set once at the start. During the course of execution, I want all current timestamp invocations to believe that the application has started at that time and will show timestamps accordingly, regardless of the real system time.
I would like to do this without changing the time of the computer and without affectiing other applications running on the computer.
Is this possible?