Class QuantityFormat


public class QuantityFormat extends Format<QuantityFormat,QuantityFormatContext>
QuantityFormat stores the settings that influence both the value part and the unit part of an output string when formatting a quantity.

Copyright (c) 2026-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
  • Constructor Details

    • QuantityFormat

      protected QuantityFormat(QuantityFormatContext ctx)
      Construct a QuantityFormat object with a given context. Note that the context can be an existing context that is being modified or a default context.
      Parameters:
      ctx - the quantity format context to use
  • Method Details

    • defaults

      public static QuantityFormat defaults()
      Return an instance of QuantityFormat, initialized with the default values.
      Returns:
      an instance of QuantityFormat, initialized with the default values
    • changeDefaults

      public static QuantityFormat changeDefaults()
      Return an instance of QuantityFormat with the DEFAULT values, which can be changed for all subsequent calls.
      Returns:
      an instance of QuantityFormat with the DEFAULT values
    • resetDefaults

      public static void resetDefaults()
      Reset the default values of QuantityFormat to their original values.
    • setScaleSiPrefixes

      public QuantityFormat setScaleSiPrefixes()
      Use closest SI prefix. E.g., turn 20400 m into "20.4 km".
      Returns:
      QuantityFormat object for fluent design
    • setScaleSiPrefixes

      public QuantityFormat setScaleSiPrefixes(int minPrefixPower, int maxPrefixPower)
      Use closest SI prefix. E.g., turn 20400 m into "20.4 km".
      Parameters:
      minPrefixPower - minimum 10th power to use SI prefixes for
      maxPrefixPower - maximum 10th power to use SI prefixes for
      Returns:
      QuantityFormat object for fluent design