Class SimpleQuantityFormat

    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.text.Format

        java.text.Format.Field
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Appendable format​(javax.measure.Quantity quantity, java.lang.Appendable dest)
      Formats the specified quantity into an Appendable.
      static SimpleQuantityFormat getInstance()
      Returns the quantity format for the default locale.
      ComparableQuantity<?> parse​(java.lang.CharSequence csq)
      Parses a portion of the specified CharSequence from the specified position to produce an object.
      (package private) AbstractQuantity<?> parse​(java.lang.CharSequence csq, int index)
      Parses a portion of the specified CharSequence from the specified position to produce an object.
      ComparableQuantity<?> parse​(java.lang.CharSequence csq, java.text.ParsePosition cursor)
      Parses a portion of the specified CharSequence from the specified position to produce an object.
      • Methods inherited from class java.text.Format

        clone, format, formatToCharacterIterator, parseObject
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SimpleQuantityFormat

        public SimpleQuantityFormat()
    • Method Detail

      • format

        public java.lang.Appendable format​(javax.measure.Quantity quantity,
                                           java.lang.Appendable dest)
                                    throws java.io.IOException
        Description copied from class: AbstractQuantityFormat
        Formats the specified quantity into an Appendable.
        Specified by:
        format in interface QuantityFormat
        Specified by:
        format in class AbstractQuantityFormat
        Parameters:
        quantity - the quantity to format.
        dest - the appendable destination.
        Returns:
        the specified Appendable.
        Throws:
        java.io.IOException - if an I/O exception occurs.
      • parse

        public ComparableQuantity<?> parse​(java.lang.CharSequence csq,
                                           java.text.ParsePosition cursor)
                                    throws javax.measure.format.ParserException
        Description copied from class: AbstractQuantityFormat
        Parses a portion of the specified CharSequence from the specified position to produce an object. If parsing succeeds, then the index of the cursor argument is updated to the index after the last character used.
        Specified by:
        parse in interface QuantityFormat
        Specified by:
        parse in class AbstractQuantityFormat
        Parameters:
        csq - the CharSequence to parse.
        cursor - the cursor holding the current parsing index.
        Returns:
        the object parsed from the specified character sub-sequence.
        Throws:
        javax.measure.format.ParserException
      • parse

        AbstractQuantity<?> parse​(java.lang.CharSequence csq,
                                  int index)
                           throws javax.measure.format.ParserException
        Description copied from class: AbstractQuantityFormat
        Parses a portion of the specified CharSequence from the specified position to produce an object. If parsing succeeds, then the index of the cursor argument is updated to the index after the last character used.
        Specified by:
        parse in class AbstractQuantityFormat
        Parameters:
        csq - the CharSequence to parse.
        index - the current parsing index.
        Returns:
        the object parsed from the specified character sub-sequence.
        Throws:
        javax.measure.format.ParserException
      • parse

        public ComparableQuantity<?> parse​(java.lang.CharSequence csq)
                                    throws javax.measure.format.ParserException
        Description copied from class: AbstractQuantityFormat
        Parses a portion of the specified CharSequence from the specified position to produce an object. If parsing succeeds, then the index of the cursor argument is updated to the index after the last character used.
        Specified by:
        parse in interface tech.uom.lib.common.function.Parser<java.lang.CharSequence,​ComparableQuantity>
        Specified by:
        parse in interface QuantityFormat
        Specified by:
        parse in class AbstractQuantityFormat
        Parameters:
        csq - the CharSequence to parse.
        Returns:
        the object parsed from the specified character sub-sequence.
        Throws:
        javax.measure.format.ParserException
      • getInstance

        public static SimpleQuantityFormat getInstance()
        Returns the quantity format for the default locale. The default format assumes the quantity is composed of a decimal number and a Unit separated by whitespace(s).
        Returns:
        MeasureFormat.getInstance(NumberFormat.getInstance(), UnitFormat.getInstance())