When System.nanotime() runs backwards


package gameloop;

/**
 *
 * @author Mario
 */
public class NanoTimeBackwards {

    public static void main(String[] args) {
        long diff = Long.MAX_VALUE - System.nanoTime();
        long days = (diff / 1000000000L) / 60 / 60 / 24;
        long years = days / 365;
        System.out.println(
                "Your nano timer will run backwards in "+years+" years.");
    }
}

Edit: Oops, was multiplying instead of dividing.

–Mario

Ha ha, clever.

actually… 2^63 / 1.000.000.000 / 3600 / 24 / 365 = 292 years

due to cpu throttling, and multicore systems with each core having it’s own time, System.nanoTime can go back in time ANY time.