Class ValueUtil

java.lang.Object
org.djunits.value.util.ValueUtil

public final class ValueUtil
extends Object
ValueUtil implements a couple of unit-related static methods.

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

Author:
Alexander Verbraeck, Peter Knoppers
  • Field Details

    • NUMBER_PATTERN

      public static final Pattern NUMBER_PATTERN
      Number pattern regex to be used in valueOf() method.
  • Method Details

    • expressAsSIUnit

      public static double expressAsSIUnit​(double value, Unit<?> unit)
      Convert a value in a given unit into the equivalent in the standard SI unit.
      Parameters:
      value - double; the value to convert into the standard SI unit
      unit - Unit<?>; the unit of the given value
      Returns:
      double; the value in the standard SI unit
    • expressAsUnit

      public static double expressAsUnit​(double siValue, Unit<?> targetUnit)
      Convert a value from the standard SI unit into a compatible unit.
      Parameters:
      siValue - double; the given value in the standard SI unit
      targetUnit - Unit<?>; the unit to convert the value into
      Returns:
      double; the value in the targetUnit