com.sas.measures
Class Time

com.sas.measures.Time
All Implemented Interfaces:
com.sas.measures.MeasureInterface, com.sas.PublicClonable, java.io.Serializable, java.lang.Cloneable

public class Time

Time provides an object which represents a span of time in one of several different time units. Time objects are immutable - you cannot change the time span or the units. You can however, create new Time objects in different units from existing time objects with the getMagnitude(Object unit) method.

The supported units, grouped by type with full name followed by abbreviation, are as follows: The names are resources in the com.sas.measures.Resources resource bundle; the abbreviations are constant. Use com.sas.measures.RB.getStringResource("Time.ps.txt") to get the label ("hour" in English) for the hour time unit. Note: No defined abbreviation for millennium is known (to us), so we chose "mille".

See Also:
Serialized Form

Field Summary
static java.lang.String RB_KEY
           
 
Fields inherited from class com.sas.measures.Measure
DISPLAY_FORMAT_NOSPACE_BETWEEN_MAGNITUDE_AND_UNIT, DISPLAY_FORMAT_SPACE_BETWEEN_MAGNITUDE_AND_UNIT, displayFormat, locale, magnitude
 
Constructor Summary
Time(double magnitude, java.lang.String unitOfTime)
          Constructs a Time object from the specified magnitude and unit of time
Time(long millis)
          Constructs a Time object from a measure of millisecnds
Time(java.lang.String text)
          Constructs a Time object from a string consisting of a numeric value and unit of time.
 
Method Summary
 double getMagnitude(java.lang.Object unit)
          Returns an equivalent magnitude of the current time measurement in terms of the specified unit of time.
 java.lang.Object getUnit()
          Returns the abbreviated name of the unit property.
 java.lang.String getUnitName()
          Returns the full name value of the unit property.
protected  void initializeUnit(java.lang.Object unit)
          Initializes a unit.
static AssociationListInterface makeUnitsAssociationList()
           
static StaticOrderedCollectionInterface makeUnitsList()
           
 boolean validateUnit(java.lang.String unit)
          Returns true if the specified unit is a supported unit of measure, false otherwise.
 
Methods inherited from class com.sas.measures.Measure
_init, clone, equals, equals, getMagnitude, hashCode, toString
 

Field Detail

RB_KEY

public static final java.lang.String RB_KEY
See Also:
Constant Field Values
Constructor Detail

Time

public Time(double magnitude,
            java.lang.String unitOfTime)
Constructs a Time object from the specified magnitude and unit of time

Parameters:
magnitude - numeric value of the measurement
unit - unit of time
Throws:
java.lang.IllegalArgumentException - if the unit is not a supported unit of time

Time

public Time(java.lang.String text)
Constructs a Time object from a string consisting of a numeric value and unit of time.

Parameters:
text - a string consisting of a number, some whitespace, and a supported units token, such as "10 s" or "2.5e12 ns"
Throws:
java.lang.IllegalArgumentException - if the unit is not a supported unit of measure

Time

public Time(long millis)
Constructs a Time object from a measure of millisecnds

Parameters:
millis -
Method Detail

getMagnitude

public double getMagnitude(java.lang.Object unit)
Returns an equivalent magnitude of the current time measurement in terms of the specified unit of time.

Specified by:
getMagnitude in interface com.sas.measures.MeasureInterface
Specified by:
getMagnitude in class com.sas.measures.Measure
Parameters:
unit - the unit of time to convert to
Returns:
the value of the current magnitude converted into the specified unit of time
Throws:
java.lang.IllegalArgumentException - if the unit is not a supported unit of time

getUnit

public java.lang.Object getUnit()
Returns the abbreviated name of the unit property. For example, "in" for inch and "cm" for centimeter.

Specified by:
getUnit in interface com.sas.measures.MeasureInterface
Specified by:
getUnit in class com.sas.measures.Measure
Returns:
unit of measure of the measurement

getUnitName

public java.lang.String getUnitName()
Returns the full name value of the unit property. This is the full name of the unit of measure

Specified by:
getUnitName in interface com.sas.measures.MeasureInterface
Specified by:
getUnitName in class com.sas.measures.Measure
Returns:
unit of measure of the measurement

initializeUnit

protected void initializeUnit(java.lang.Object unit)
Initializes a unit. This is called by the superclass when a new Distance object is being constructed. This method should only be called while an object is being constructed.

Specified by:
initializeUnit in class com.sas.measures.Measure
Parameters:
unit - the unit to initialize
Throws:
java.lang.IllegalArgumentException - if the unit is not a supported unit of measure

validateUnit

public boolean validateUnit(java.lang.String unit)
Returns true if the specified unit is a supported unit of measure, false otherwise.

Parameters:
unit - the unit of measure to validate

makeUnitsAssociationList

public static AssociationListInterface makeUnitsAssociationList()

makeUnitsList

public static StaticOrderedCollectionInterface makeUnitsList()



Copyright © 2009 SAS Institute Inc. All Rights Reserved.