Class Temperature

All Implemented Interfaces:
Serializable, Comparable<Temperature>, Value<Temperature.Unit,Temperature>

Temperature is the absolute equivalent of Temperature, and represents a true temperature rather than a temperature difference.

Copyright (c) 2025-2026 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djunits.org. The DJUNITS project is distributed under a three-clause BSD-style license.

Author:
Alexander Verbraeck
See Also:
  • Constructor Details

    • Temperature

      public Temperature(double value, Temperature.Unit unit, Temperature.Reference reference)
      Instantiate a Temperature quantity with a unit and a reference point.
      Parameters:
      value - the temperature value, expressed in a temperature unit
      unit - the temperature unit in which the value is expressed, relative to the reference point
      reference - the reference point of this absolute temperature
    • Temperature

      public Temperature(double value, Temperature.Unit unit)
      Instantiate a Temperature quantity with a unit and the KELVIN reference point.
      Parameters:
      value - the temperature value, expressed in a temperature unit
      unit - the temperature unit in which the value is expressed, relative to the reference point
    • Temperature

      public Temperature(double value, String abbreviation, Temperature.Reference reference)
      Instantiate a Temperature quantity with a unit, expressed as a String, and a reference point.
      Parameters:
      value - the temperature value, expressed in the unit, relative to the reference point
      abbreviation - the String abbreviation of the unit in which the value is expressed
      reference - the reference point of this absolute temperature
    • Temperature

      public Temperature(double value, String abbreviation)
      Instantiate a Temperature quantity with a unit, expressed as a String, and the reference point belonging to the unit.
      Parameters:
      value - the temperature value, expressed in the unit, relative to the reference point
      abbreviation - the String abbreviation of the unit in which the value is expressed
    • Temperature

      public Temperature(TemperatureDifference temperature, Temperature.Reference reference)
      Instantiate a Temperature instance based on an temperature and a reference point.
      Parameters:
      temperature - the temperature, relative to the reference point
      reference - the reference point of this absolute temperature
    • Temperature

      public Temperature(TemperatureDifference temperature)
      Instantiate a Temperature instance based on an temperature and the KELVIN reference point.
      Parameters:
      temperature - the temperature, relative to the reference point
  • Method Details

    • ofSi

      public static Temperature ofSi(double si, Temperature.Reference reference)
      Return a Temperature instance based on an SI value and a reference point.
      Parameters:
      si - the temperature si value, relative to the reference point
      reference - the reference point of this absolute temperature
      Returns:
      the Temperature instance based on an SI value
    • ofSi

      public static Temperature ofSi(double si)
      Return a Temperature instance based on an SI value and the KELVIN reference point.
      Parameters:
      si - the temperature si value, relative to the reference point
      Returns:
      the Temperature instance based on an SI value
    • instantiate

      public Temperature instantiate(TemperatureDifference temperature, Temperature.Reference reference)
      Description copied from class: AbsoluteQuantity
      Instantiate an absolute quantity with a quantity and a reference.
      Specified by:
      instantiate in class AbsoluteQuantity<Temperature,TemperatureDifference,Temperature.Unit,Temperature.Reference>
      Parameters:
      temperature - the relative quantity that indicates the 'distance' to the reference point
      reference - the reference point
      Returns:
      the absolute quantity with a quantity and a reference
    • siUnit

      public SIUnit siUnit()
      Description copied from class: AbsoluteQuantity
      Return the SI unit of this quantity.
      Overrides:
      siUnit in class AbsoluteQuantity<Temperature,TemperatureDifference,Temperature.Unit,Temperature.Reference>
      Returns:
      the SI unit of this quantity
    • valueOf

      public static Temperature valueOf(String text, Temperature.Reference reference)
      Returns a Temperature representation of a textual representation of a value with a unit. The String representation that can be parsed is the double value in the unit, followed by a localized or English abbreviation of the unit. Spaces are allowed, but not required, between the value and the unit.
      Parameters:
      text - the textual representation to parse into a Temperature
      reference - the reference point of this absolute temperature
      Returns:
      the Scalar representation of the value in its unit
      Throws:
      IllegalArgumentException - when the text cannot be parsed
      NullPointerException - when the text argument is null
    • valueOf

      public static Temperature valueOf(String text)
      Returns a Temperature representation of a textual representation of a value with a unit, and the KELVIN reference. The String representation that can be parsed is the double value in the unit, followed by a localized or English abbreviation of the unit. Spaces are allowed, but not required, between the value and the unit.
      Parameters:
      text - the textual representation to parse into a Temperature
      Returns:
      the Scalar representation of the value in its unit
      Throws:
      IllegalArgumentException - when the text cannot be parsed
      NullPointerException - when the text argument is null
    • of

      public static Temperature of(double value, String unitString, Temperature.Reference reference)
      Returns a Temperature based on a value and the textual representation of the unit, which can be localized.
      Parameters:
      value - the value to use
      unitString - the textual representation of the unit
      reference - the reference point of this absolute temperature
      Returns:
      the Scalar representation of the value in its unit
      Throws:
      IllegalArgumentException - when the unit cannot be parsed or is incorrect
      NullPointerException - when the unitString argument is null
    • of

      public static Temperature of(double value, String unitString)
      Returns a Temperature based on a value and the textual representation of the unit, which can be localized. Use the KELVIN reference.
      Parameters:
      value - the value to use
      unitString - the textual representation of the unit
      Returns:
      the Scalar representation of the value in its unit
      Throws:
      IllegalArgumentException - when the unit cannot be parsed or is incorrect
      NullPointerException - when the unitString argument is null
    • subtract

      public TemperatureDifference subtract(Temperature other)
      Description copied from class: AbsoluteQuantity
      Subtract two absolute quantities from each other, resulting in the corresponding relative quantity. The unit of the resulting quantity will be the unit of 'this' absolute quantity. Quantity 'other' will be transformed to the reference point of this absolute quantity. If the reference points of this and other are different, and no transformations between the reference points exist, an exception will be thrown.
      Specified by:
      subtract in class AbsoluteQuantity<Temperature,TemperatureDifference,Temperature.Unit,Temperature.Reference>
      Parameters:
      other - the absolute quantity to subtract
      Returns:
      the relative quantity as a result of the subtraction
    • add

      public Temperature add(TemperatureDifference other)
      Description copied from class: AbsoluteQuantity
      Add a relative quantity to this absolute quantity, resulting in a new absolute quantity containing the sum. The new quantity will have the same reference point and unit as this absolute quantity.
      Specified by:
      add in class AbsoluteQuantity<Temperature,TemperatureDifference,Temperature.Unit,Temperature.Reference>
      Parameters:
      other - the relative quantity to add
      Returns:
      the absolute quantity as a result of the addition
    • subtract

      public Temperature subtract(TemperatureDifference other)
      Description copied from class: AbsoluteQuantity
      Subtract a relative quantity from this absolute quantity, resulting in a new absolute quantity containing the difference. The new quantity will have the same reference point and unit as this absolute quantity.
      Specified by:
      subtract in class AbsoluteQuantity<Temperature,TemperatureDifference,Temperature.Unit,Temperature.Reference>
      Parameters:
      other - the relative quantity to subtract
      Returns:
      the absolute quantity as a result of the subtraction