javax.cim
Class CIMDateTimeInterval

java.lang.Object
  extended by javax.cim.CIMDateTime
      extended by javax.cim.CIMDateTimeInterval
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<CIMDateTime>

public class CIMDateTimeInterval
extends CIMDateTime

This class represents the datetime data type when used as a time value as specified by the Distributed Management Task Force (DMTF) CIM Infrastructure Specification (DSP004). It is in the format ddddddddHHMMSS.mmmmmm:000 where:

For example, an elapsed time of 1 day, 13 hours, 23 minutes, 12 seconds would be: 00000001132312.000000:000. A UTC offset of zero is always used for interval properties.
Fields that are not significant MUST be replaced with asterisk ("*") characters. Not significant fields are those that are beyond the resolution of the data source. This is used to indicate the precision of the value and can only be done for an adjacent set of fields, starting with the least significant field (mmmmmm), and continuing to more significant fields. The granularity of using asterisks is always the entire field, except for the mmmmmm field where the granularity is single digits. The UTC offset field MUST NOT contain asterisks.
For example, if an interval of 1 day, 13 hours, 23 minutes, 12 seconds, and 125 milliseconds was measured with a precision of 1 millisecond, the format would be: 00000001132312.125***:000.

See Also:
Serialized Form

Constructor Summary
CIMDateTimeInterval(int pDays, int pHours, int pMinutes, int pSeconds, int pMicroseconds)
          Constructs a CIMDateTimeInterval using the individual values of the interval (day, hours, minutes, seconds and microseconds).
CIMDateTimeInterval(long pMilliseconds)
          Constructs a CIMDateTimeInterval using a milliseconds value.
CIMDateTimeInterval(java.lang.String pIntervalString)
          Creates a CIMDateTimeInterval object using a string.
 
Method Summary
 int compareTo(CIMDateTime pObj)
          Compares the CIMDateTimeInterval object with this one.
 boolean equals(java.lang.Object pObj)
          Determines whether the CIMDateTimeInterval that is passed in is equal to the current CIMDateTimeInterval object.
 java.lang.String getDateTimeString()
          Gets the internal string representation of this object.
 int getDays()
          Returns days value of this interval.
 int getHours()
          Returns hours value of this interval.
 int getMicroseconds()
          Returns microseconds value of this interval.
 int getMinutes()
          Returns minutes value of this interval.
 int getSeconds()
          Returns seconds value of this interval.
 long getTotalMilliseconds()
          Returns the total length of the interval in milliseconds.
 int hashCode()
          Returns the hash code for this object.
 java.lang.String toString()
          Returns a String representation of the CIMDateTimeInterval.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CIMDateTimeInterval

public CIMDateTimeInterval(int pDays,
                           int pHours,
                           int pMinutes,
                           int pSeconds,
                           int pMicroseconds)
                    throws java.lang.IllegalArgumentException
Constructs a CIMDateTimeInterval using the individual values of the interval (day, hours, minutes, seconds and microseconds). Any property that has a -1 will make that field "not significant" (i.e. that field has asterisks in the datetime string).

Parameters:
pDays - Number of days in the interval (-1 - 99999999).
pHours - Number of hours in the interval (-1 - 23).
pMinutes - Number of minutes in the interval (-1 - 59).
pSeconds - Number of seconds in the interval (-1 - 59).
pMicroseconds - Number of microseconds in the interval (-1 - 999999).
Throws:
java.lang.IllegalArgumentException

CIMDateTimeInterval

public CIMDateTimeInterval(long pMilliseconds)
                    throws java.lang.IllegalArgumentException
Constructs a CIMDateTimeInterval using a milliseconds value.

Parameters:
pMilliseconds - Number of milliseconds in the interval (0 - 8639999999999999).
Throws:
java.lang.IllegalArgumentException

CIMDateTimeInterval

public CIMDateTimeInterval(java.lang.String pIntervalString)
                    throws java.lang.IllegalArgumentException
Creates a CIMDateTimeInterval object using a string.

Parameters:
pIntervalString - A string in the format of ddddddddHHMMSS.mmmmmm:000.
Throws:
java.lang.IllegalArgumentException - If string is not in the correct format.
Method Detail

compareTo

public int compareTo(CIMDateTime pObj)
              throws java.lang.IllegalArgumentException
Compares the CIMDateTimeInterval object with this one. If either interval has "Not Significant" fields then we only compare the significant fields.

Parameters:
pObj - The CIMDateTimeInterval to be compared with this one.
Returns:
-1, zero, or 1 as this interval is less than, equal to, or greater than the specified interval.
Throws:
java.lang.IllegalArgumentException - If the object passed in is not an instance of CIMDataTimeInterval.

equals

public boolean equals(java.lang.Object pObj)
Determines whether the CIMDateTimeInterval that is passed in is equal to the current CIMDateTimeInterval object.

Overrides:
equals in class CIMDateTime
Parameters:
pObj - The CIMDateTimeInterval object to compare to.
Returns:
true if this CIMDateTimeInterval object is equal to the one that was passed in, otherwise false.

getDateTimeString

public java.lang.String getDateTimeString()
Gets the internal string representation of this object.

Specified by:
getDateTimeString in class CIMDateTime
Returns:
The internal representation of the CIMDateTimeInterval object.

getDays

public int getDays()
Returns days value of this interval.

Returns:
If days field "not significant" this returns -1, otherwise returns number of days in the interval.

getHours

public int getHours()
Returns hours value of this interval.

Returns:
If hours field "not significant" this returns -1, otherwise returns number of hours in the interval.

getMicroseconds

public int getMicroseconds()
Returns microseconds value of this interval.

Returns:
If microseconds field "not significant" this returns -1, otherwise returns number of microseconds in the interval.

getMinutes

public int getMinutes()
Returns minutes value of this interval.

Returns:
If minutes field "not significant" this returns -1, otherwise returns number of minutes in the interval.

getSeconds

public int getSeconds()
Returns seconds value of this interval.

Returns:
If seconds field "not significant" this returns -1, otherwise returns number of seconds in the interval.

getTotalMilliseconds

public long getTotalMilliseconds()
Returns the total length of the interval in milliseconds.

Returns:
The length of the interval in milliseconds.

hashCode

public int hashCode()
Returns the hash code for this object.

Specified by:
hashCode in class CIMDateTime
Returns:
A hash code value for this object.
See Also:
Object.hashCode()

toString

public java.lang.String toString()
Returns a String representation of the CIMDateTimeInterval. This method is intended to be used only for debugging purposes, and the format of the returned string may vary between implementations. The returned string may be empty but may not be null.

Overrides:
toString in class java.lang.Object
Returns:
String representation of this datetime.


Copyright © 2005, 2011 IBM Corporation. All Rights Reserved.