Package com.openinventor.inventor
Class SbTime
java.lang.Object
com.openinventor.inventor.Inventor
com.openinventor.inventor.SbTime
- All Implemented Interfaces:
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:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class com.openinventor.inventor.Inventor
Inventor.ConstructorCommand
-
Field Summary
FieldsFields inherited from class com.openinventor.inventor.Inventor
VERBOSE_LEVEL, ZeroHandle
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Addition of two times which modifies the time structure.int
void
divide
(double s) Destructive division by scalar.boolean
format()
Calls format("%S.%i").Convert to a string.Calls formatDate(DEFAULT_FORMAT_DATE).formatDate
(String fmt) Convert to a date string, interpreting the time as seconds since Jan 1, 1970.double
Get time in seconds as a double.long
Get time in milliseconds (for Xt).static SbTime
Get the current time (seconds since Jan 1, 1970).getValue()
Get time in seconds and microseconds.static SbTime
maxTime()
Get a time far, far into the future.Subtraction of two times.void
multiply
(double s) Destructive multiplication by scalar.over
(double s) Division by scalar.double
Division by another time.Addition of two times.Modulus for two times (remainder when time1 is divided by time2).void
setMsecValue
(long msec) Set time from milliseconds.void
Set to the current time (seconds since Jan 1, 1970).void
setValue
(double sec) Set time from a double (in seconds).void
setValue
(long sec, long usec) Set time from seconds + microseconds.void
static void
sleep
(int msec) Sleep for specified time (in msec).void
Subtraction of two times which modifies the time structure.times
(double s) Multiplication by scalar.static SbTime[]
toArray
(long nativeArray, long length) static void
usleep
(long usec) Sleep for specified time (in microsec).static SbTime
zero()
Get a zero time.Methods inherited from class com.openinventor.inventor.Inventor
dispose, getNativeResourceHandle
-
Field Details
-
DEFAULT_FORMAT_DATE
- See Also:
-
-
Constructor Details
-
SbTime
-
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 whichSbTime(1)
had different semantics. In future releases, this distinction will be eliminated, and the effect ofSbTime
(1.0) and that ofSbTime(1)
will be identical.
-
-
Method Details
-
formatDate
Calls formatDate(DEFAULT_FORMAT_DATE). -
format
Calls format("%S.%i"). -
compareTo
- Specified by:
compareTo
in interfaceComparable
-
zero
Get a zero time. -
getValue
Get time in seconds and microseconds. -
sleep
public static void sleep(int msec) Sleep for specified time (in msec). -
setValue
-
format
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 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.\% 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) -
getMsecValue
public long getMsecValue()Get time in milliseconds (for Xt). -
toArray
-
usleep
public static void usleep(long usec) Sleep for specified time (in microsec). -
maxTime
Get a time far, far into the future. Replace the deprecated SbTime.max() method. -
formatDate
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
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
Multiplication by scalar. -
setMsecValue
public void setMsecValue(long msec) Set time from milliseconds. -
add
Addition of two times which modifies the time structure. -
multiply
public void multiply(double s) Destructive multiplication by scalar. -
over
Division by another time. -
substract
Subtraction of two times which modifies the time structure. -
setToTimeOfDay
public void setToTimeOfDay()Set to the current time (seconds since Jan 1, 1970). -
getTimeOfDay
Get the current time (seconds since Jan 1, 1970). -
plus
Addition of two times. -
remainder
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
-
minus
Subtraction of two times.
-