Class NumberTime

  • All Implemented Interfaces:
    Serializable

    public class NumberTime
    extends Number
    implements Serializable
    Wrapper for a Number or float/double with Unit of type Time. Store it internally as a Number or as a DoubleScalar, or as a FloatScalar and have methods to retrieve it in different ways.

    Copyright (c) 2016-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
    BSD-style license. See Sim0MQ License.

    $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $, initial version Apr 24, 2017
    Author:
    Alexander Verbraeck
    See Also:
    Serialized Form
    • Constructor Detail

      • NumberTime

        public NumberTime​(Number time)
        Create a time from a Number.
        Parameters:
        time - the time as a Number.
      • NumberTime

        public NumberTime​(Time time)
        Create a time from a DoubleScalar Time type.
        Parameters:
        time - the time as a DoubleScalar Time.
      • NumberTime

        public NumberTime​(FloatTime time)
        Create a time from a FloatScalar FloatTime type.
        Parameters:
        time - the time as a FloatScalar FloatTime.
    • Method Detail

      • instantiate

        public static NumberTime instantiate​(Object value)
                                      throws Sim0MQException
        Instantiate a NumberTime based on a value.
        Parameters:
        value - the value that can be Time, FloatTime, or Number
        Returns:
        an instantiation of NumberTime
        Throws:
        Sim0MQException - if the value is neither Time, FloatTime, nor Number
      • intValue

        public int intValue()
        Specified by:
        intValue in class Number
      • longValue

        public long longValue()
        Specified by:
        longValue in class Number
      • floatValue

        public float floatValue()
        Specified by:
        floatValue in class Number
      • doubleValue

        public double doubleValue()
        Specified by:
        doubleValue in class Number
      • getObject

        public Object getObject()
        Return the NumberTime as an object, e.g., for serializing.
        Returns:
        NumberTime as an object
      • getNumber

        public Number getNumber()
        Returns:
        the time as a Number
      • getTime

        public Time getTime()
        Returns:
        the time as a djunits Time type
      • getFloatTime

        public FloatTime getFloatTime()
        Returns:
        the time as a djunits FloatTime type