Class SbTime

java.lang.Object
com.openinventor.inventor.Inventor
com.openinventor.inventor.SbTime
All Implemented Interfaces:
Comparable

public class SbTime extends Inventor implements Comparable
Class for representation of a time. This class represents and performs operations on time. Operations may be done in seconds, seconds and microseconds, or using a struct timeval (defined in time.h ).

See Also:
  • Field Details

  • Constructor Details

    • SbTime

      public SbTime(SbTime copyFrom)
    • SbTime

      public SbTime(long sec, long usec)
      Constructor taking seconds and microseconds.
    • SbTime

      public SbTime()
      Default constructor. The time value is not initialized.
    • SbTime

      public SbTime(double sec)
      Constructor taking seconds. NOTE that an integer parameter will not automatically cast to a double to invoke the constructor taking seconds; that is, SbTime(1) will result in a compilation error. SbTime(1.0) must be used instead. This is to avoid errors in upgrading from an earlier release, in which SbTime(1) had different semantics. In future releases, this distinction will be eliminated, and the effect of SbTime(1.0) and that of SbTime(1) will be identical.
  • Method Details

    • formatDate

      public String formatDate()
      Calls formatDate(DEFAULT_FORMAT_DATE).
    • format

      public String format()
      Calls format("%S.%i").
    • compareTo

      public int compareTo(Object obj)
      Specified by:
      compareTo in interface Comparable
    • zero

      public static SbTime zero()
      Get a zero time.
    • getValue

      public SbTime.TimeVal getValue()
      Get time in seconds and microseconds.
    • sleep

      public static void sleep(int msec)
      Sleep for specified time (in msec).
    • setValue

      public void setValue(SbTime copyFrom)
    • format

      public String format(String fmt)
      Convert to a string. The default format is seconds with 3 digits of fraction precision. fmt is a character string that consists of field descriptors and text characters, in a manner analogous to printf(). Each field descriptor consists of a % character followed by another character which specifies the replacement for the field descriptor. All other characters are copied from fmt into the result. The following field descriptors are supported:
        \%  the `\%' character
        D  total number of days
        H  total number of hours
        M  total number of minutes
        S  total number of seconds
        I  total number of milliseconds
        U  total number of microseconds
        h  hours remaining after the days (00-23)
        m  minutes remaining after the hours (00-59)
        s  seconds remaining after the minutes (00-59)
        i  milliseconds remaining after the seconds (000-999)
        u  microseconds remaining after the seconds (000000-999999)
      
      The uppercase descriptors are formatted with a leading `-' for negative times; the lowercase descriptors are formatted fixed width, with leading zeros. For example, a reasonable format string might be "elapsed time: \%M minutes, \%s seconds". The default value of fmt, "\%S.\%i", formats the time as seconds with 3 digits of fractional precision.
    • getMsecValue

      public long getMsecValue()
      Get time in milliseconds (for Xt).
    • toArray

      public static SbTime[] toArray(long nativeArray, long length)
    • usleep

      public static void usleep(long usec)
      Sleep for specified time (in microsec).
    • maxTime

      public static SbTime maxTime()
      Get a time far, far into the future. Replace the deprecated SbTime.max() method.
    • formatDate

      public String formatDate(String fmt)
      Convert to a date string, interpreting the time as seconds since Jan 1, 1970. The default format gives "Tuesday, 01/26/93 11:23:41 AM". See the strftime() reference page for explanation of the format string.
    • setValue

      public void setValue(long sec, long usec)
      Set time from seconds + microseconds.
    • over

      public SbTime over(double s)
      Division by scalar.
    • getDoubleValue

      public double getDoubleValue()
      Get time in seconds as a double.
    • divide

      public void divide(double s)
      Destructive division by scalar.
    • times

      public SbTime times(double s)
      Multiplication by scalar.
    • setMsecValue

      public void setMsecValue(long msec)
      Set time from milliseconds.
    • add

      public void add(SbTime tm)
      Addition of two times which modifies the time structure.
    • multiply

      public void multiply(double s)
      Destructive multiplication by scalar.
    • over

      public double over(SbTime tm)
      Division by another time.
    • substract

      public void substract(SbTime tm)
      Subtraction of two times which modifies the time structure.
    • setToTimeOfDay

      public void setToTimeOfDay()
      Set to the current time (seconds since Jan 1, 1970).
    • getTimeOfDay

      public static SbTime getTimeOfDay()
      Get the current time (seconds since Jan 1, 1970).
    • plus

      public SbTime plus(SbTime t1)
      Addition of two times.
    • remainder

      public SbTime remainder(SbTime tm)
      Modulus for two times (remainder when time1 is divided by time2).
    • setValue

      public void setValue(double sec)
      Set time from a double (in seconds).
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • minus

      public SbTime minus(SbTime t1)
      Subtraction of two times.