private static void printStartStopTimes() {
        final long start = System.currentTimeMillis();

        System.err.println("Start at " + new Date());

        Thread hook = new Thread(() -> {
            long timePassed = System.currentTimeMillis() - start;
            System.err.println("Stop at " + new Date() + ", execution time = " + timePassed + " ms");
        });
        Runtime.getRuntime().addShutdownHook(hook);
    }
Print the start message to System.err with the time NOW, and register a
shutdown hook which will print the stop message to System.err with the
time then and the number of milliseconds passed since.
slf4j-ext/src/main/java/org/slf4j/agent/AgentPremain.java