Interface QuantityFormat


public interface QuantityFormat
Formats instances of Quantity.
Synchronization
Instances of this class are not required to be thread-safe. It is recommended to use separate format instances for each thread. If multiple threads access a format concurrently, it must be synchronized externally.
Since:
2.0
Version:
1.1, 20 May, 2023
Author:
Werner Keil, Thodoris Bais
See Also:
  • Method Details

    • format

      Appendable format(Quantity<?> quantity, Appendable destination) throws IOException
      Formats the specified quantity into an Appendable.
      Parameters:
      quantity - the quantity to format.
      destination - the appendable destination.
      Returns:
      the specified Appendable.
      Throws:
      IOException - if an I/O exception occurs.
    • format

      String format(Quantity<?> quantity)
      Formats the specified Quantity.
      Parameters:
      quantity - the Quantity to format, not null
      Returns:
      the string representation using the settings of this QuantityFormat.
    • parse

      Parses a portion of the specified CharSequence from the specified position to produce a Quantity. If parsing succeeds, then the index of the pos argument is updated to the index after the last character used.
      Parameters:
      csq - the CharSequence to parse.
      pos - a ParsePosition object holding the current parsing index and error parsing index information as described above.
      Returns:
      the quantity parsed from the specified character sub-sequence.
      Throws:
      MeasurementParseException - if any problem occurs while parsing the specified character sequence (e.g. illegal syntax).
    • parse

      Parses the specified CharSequence to produce a Quantity.

      The parse must complete normally and parse the entire text. If the parse completes without reading the entire length of the text, an exception is thrown. If any other problem occurs during parsing, an exception is thrown.

      Parameters:
      csq - the CharSequence to parse.
      Returns:
      the quantity parsed from the specified character sub-sequence.
      Throws:
      MeasurementParseException - if any problem occurs while parsing the specified character sequence (e.g. illegal syntax).
    • isLocaleSensitive

      default boolean isLocaleSensitive()
      Returns true if this QuantityFormat depends on a Locale to perform its tasks.

      In environments that do not support a Locale, e.g. Java ME, this usually returns false.

      Returns:
      whether this format depends on the locale.