Package ucar.units

Class TimeScaleUnit

  • All Implemented Interfaces:
    Serializable, Unit

    @Immutable
    public final class TimeScaleUnit
    extends UnitImpl
    Provides support for a reference time unit whose origin is at a certain time.

    Instances of this class are immutable.

    See Also:
    Serialized Form
    • Method Detail

      • getUnit

        public Unit getUnit()
        Returns the reference unit.
        Returns:
        The reference unit.
      • getOrigin

        public Date getOrigin()
        Returns the time origin.
        Returns:
        The time origin.
      • clone

        public Unit clone​(UnitName id)
        Clones this unit, changing the identifier.
        Parameters:
        id - The new identifier.
        Returns:
        This unit with the new identifier.
      • shiftTo

        public Unit shiftTo​(double origin)
                     throws ShiftException
        Description copied from interface: Unit
        Returns a unit identical to this instance but whose origin (i.e., zero value) has been shifted to the given value. For example, if degK is a Kelvin unit, then degK.shiftTo(273.15) is a Celsius unit.
        Specified by:
        shiftTo in interface Unit
        Overrides:
        shiftTo in class UnitImpl
        Parameters:
        origin - The new origin in units of this instance.
        Returns:
        A unit convertible with this instance but whose zero value is equal to the value origin of this instance.
        Throws:
        ShiftException - if the corresponding new unit can't be created.
      • shiftTo

        public Unit shiftTo​(Date origin)
                     throws ShiftException
        Description copied from interface: Unit
        Returns a unit identical to this instance but whose origin (i.e., zero value) has been shifted to the given time. For example, if sec is a second unit, then sec.shiftTo(new Date(0L) is the unit corresponding to seconds since the epoch (1970-01-01 00:00:00 UTC).
        Specified by:
        shiftTo in interface Unit
        Overrides:
        shiftTo in class UnitImpl
        Parameters:
        origin - The new origin.
        Returns:
        A unit whose zero value is the time given by origin.
        Throws:
        ShiftException - if the corresponding new unit can't be created. For example, if this instance isn't a unit of time.
      • myMultiplyBy

        protected Unit myMultiplyBy​(Unit that)
                             throws MultiplyException
        Multiplies this unit by another unit. This operation is invalid.
        Specified by:
        myMultiplyBy in class UnitImpl
        Parameters:
        that - The other unit.
        Returns:
        The product of multiplying this unit by the other unit.
        Throws:
        MultiplyException - Illegal operation. Always thrown.
      • myDivideBy

        protected Unit myDivideBy​(Unit that)
                           throws DivideException
        Divides this unit by another unit. This operation is invalid.
        Specified by:
        myDivideBy in class UnitImpl
        Parameters:
        that - The other unit.
        Returns:
        The quotient of dividing this unit by the other unit.
        Throws:
        DivideException - Illegal operation. Always thrown.
      • myDivideInto

        protected Unit myDivideInto​(Unit that)
                             throws DivideException
        Divides this unit into another unit. This operation is invalid.
        Specified by:
        myDivideInto in class UnitImpl
        Parameters:
        that - The other unit.
        Returns:
        The quotient of dividing this unit into the other unit.
        Throws:
        DivideException - Illegal operation. Always thrown.
      • myRaiseTo

        protected Unit myRaiseTo​(int power)
                          throws RaiseException
        Raises this unit to a power. This operation is invalid.
        Specified by:
        myRaiseTo in class UnitImpl
        Parameters:
        power - The power.
        Returns:
        The result of raising this unit to the power.
        Throws:
        RaiseException - Illegal operation. Always thrown.
      • getDerivedUnit

        public DerivedUnit getDerivedUnit()
        Returns the derived unit underlying the reference time unit.
        Returns:
        The derived unit underlying the reference time unit.
      • isCompatible

        public final boolean isCompatible​(Unit that)
        Indicates if numeric values in this unit are convertible to another unit.
        Specified by:
        isCompatible in interface Unit
        Overrides:
        isCompatible in class UnitImpl
        Parameters:
        that - The other unit.
        Returns:
        true if and only if numeric values in this unit are convertible to that.
      • equals

        public boolean equals​(Object object)
        Indicates if this unit is semantically identical to an object.
        Specified by:
        equals in interface Unit
        Overrides:
        equals in class Object
        Parameters:
        object - The object.
        Returns:
        true if and only if this unit is semantically identical to object .
      • hashCode

        public int hashCode()
        Returns the hash code of this instance.
        Specified by:
        hashCode in class UnitImpl
        Returns:
        The hash code of this instance.
      • isDimensionless

        public boolean isDimensionless()
        Indicates if this unit is dimensionless. TimeScaleUnit-s are never dimensionless.
        Returns:
        false.
      • toString

        public String toString()
        Returns the string representation of this unit.
        Specified by:
        toString in interface Unit
        Overrides:
        toString in class UnitImpl
        Returns:
        The string representation of this unit.
      • getCanonicalString

        public String getCanonicalString()
        Returns the canonical string representation of the unit.
        Returns:
        The canonical string representation.