public class TibDateTime
extends java.lang.Object
implements java.lang.Comparable<java.lang.Object>
tibDateTime
values combine two numeric components.
sec
component represents whole seconds with up to 64 bits.
Zero denotes the UNIX epoch -- midnight entering January 1, 1970. nsec
component represents nanoseconds
after the time that the sec
component denotes.
Although the struct stores this component in a signed 64-bit integer,
this component is always non-negative, between zero
and 999999999. Constructor and Description |
---|
TibDateTime()
Create a TibDateTime object denoting January 1,
1970, 00:00:00.000000000 GMT (that is, the epoch).
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(java.lang.Object obj)
Compare this TibDateTime object to the method's argument.
|
boolean |
equals(java.lang.Object obj)
Test equivalence of this TibDateTime object to the method's argument.
|
long |
getNanoseconds()
Get the nanoseconds component of a TibDateTime object.
|
long |
getSeconds()
Get the seconds component of a TibDateTime object.
|
int |
hashCode()
Return a hash code value for this TibDateTime.
|
void |
set(long sec,
long nsec)
Modify a TibDateTime object by setting its seconds and nanoseconds components.
|
void |
setFromDate(java.util.Date date)
Modify a TibDateTime object so it represents a time equivalent to a
java.util.Date object. |
void |
setFromMillis(long millis)
Modify a TibDateTime object by converting from milliseconds
relative to January 1, 1970, 00:00:00 GMT (that is, the
epoch), and setting its components to the equivalent time.
|
java.util.Date |
toDate()
Convert a TibDateTime object to a
java.util.Date object. |
long |
toMillis()
Convert a TibDateTime object to milliseconds.
|
java.lang.String |
toString()
Return a printable string representing this TibDateTime.
|
public TibDateTime()
public void set(long sec, long nsec) throws FTLInvalidArgumentException
sec
- Positive values represent seconds since the epoch.
Negative values represent seconds before the epoch.nsec
- Nanoseconds after the time that the sec
field denotes;
must be in the range [0, 999999999].FTLInvalidArgumentException
- if the value supplied for
nanoseconds is not in the range [0, 999999999].public void setFromMillis(long millis)
millis
- Positive values represent milliseconds since the epoch.
Negative values represent milliseconds before the epoch.public void setFromDate(java.util.Date date)
java.util.Date
object.date
- A java.util.Date
objectpublic long getSeconds()
Seconds are relative to the epoch -- namely January 1, 1970, 00:00:00 GMT.
public long getNanoseconds()
Nanoseconds are after the time that the seconds
component denotes.
public long toMillis() throws FTLOutOfRangeException
Milliseconds are relative to the epoch -- namely January 1, 1970, 00:00:00 GMT.
FTLOutOfRangeException
- if the TibDateTime value is beyond the range
that can be represented as milliseconds.public java.util.Date toDate() throws FTLOutOfRangeException
java.util.Date
object.
The precision of java.util.Date
objects is milliseconds.
When converting, this method rounds to the nearest millisecond.
java.util.Date
objectFTLOutOfRangeException
- if the TibDateTime value is beyond the range
that a java.util.Date
object can represent.public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- The second object in the equivalence.true
when this TibDateTime is equivalent to the method's argumentfalse
otherwise (including when the argument is not a TibDateTime instance)public java.lang.String toString()
toString
in class java.lang.Object
public int compareTo(java.lang.Object obj)
compareTo
in interface java.lang.Comparable<java.lang.Object>
obj
- The second object in the comparison.java.lang.ClassCastException
- if the method's argument
is not a TibDateTime instance.