Class Timer

java.lang.Object
org.alban098.common.Timer

public final class Timer extends Object
This class represent an accurate timer used to calculate update and frame times
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private long
    The time at which the last frame has ended
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates and initializes a new Timer
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Get the elapsed time since the last call of this method
    double
    Get the time of the last call to getElapsedTime() in seconds
    long
    Get the current tim in seconds, accurate to nanoseconds

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • lastFrameTime

      private long lastFrameTime
      The time at which the last frame has ended
  • Constructor Details

    • Timer

      public Timer()
      Creates and initializes a new Timer
  • Method Details

    • getTime

      public long getTime()
      Get the current tim in seconds, accurate to nanoseconds
      Returns:
      the current time in seconds
    • getElapsedTime

      public double getElapsedTime()
      Get the elapsed time since the last call of this method
      Returns:
      elapsed time since last call, in seconds
    • getLastFrameTime

      public double getLastFrameTime()
      Get the time of the last call to getElapsedTime() in seconds
      Returns:
      the time of the last call to getElapsedTime() in seconds