LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: Grilled on March 30, 2015, 14:05:50

Title: Question about Time
Post by: Grilled on March 30, 2015, 14:05:50
Quick question. Printing System.getTimeMillis()/1000 results in the time in seconds from January 1, 1999- or something like that right? Please correct me if I'm wrong. How would you reset this to display time in seconds starting at 0,1,2,3...?
Title: Re: Question about Time
Post by: SHC on March 30, 2015, 14:46:22
I simply add elapsed time to a variable to achieve this.


long start = getCurrentTime(); // This is your method that returns time in seconds
long now  = start;
long elapsed;

while (running)
{
    now = getCurrentTime();
    elapsed = now - start;

    System.out.println(elapsed);
}


This example prints out the number of seconds starting from 0.