Top Description Methods
javax.measure.format

public Interface QuantityFormat

Imports
java.io.IOException, java.text.ParsePosition, javax.measure.Quantity

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.
Authors
Werner Keil, Thodoris Bais
Since
2.0
Version
1.1, 20 May, 2023
See Also
Quantity

Method Summary

Modifier and TypeMethod and Description
public Appendable

Returns:

the specified Appendable.
format
(Quantity<?>
the quantity to format.
quantity
,
Appendable
the appendable destination.
destination
)

Formats the specified quantity into an Appendable.

public String

Returns:

the string representation using the settings of this QuantityFormat.
format
(Quantity<?>
the Quantity to format, not null
quantity
)

Formats the specified Quantity.

public default boolean

Returns:

whether this format depends on the locale.
isLocaleSensitive
()

Returns true if this QuantityFormat depends on a Locale to perform its tasks.

public Quantity<?>

Returns:

the quantity parsed from the specified character sub-sequence.
parse
(CharSequence
the CharSequence to parse.
csq
,
ParsePosition
a ParsePosition object holding the current parsing index and error parsing index information as described above.
pos
)

Parses a portion of the specified CharSequence from the specified position to produce a Quantity.

public Quantity<?>

Returns:

the quantity parsed from the specified character sub-sequence.
parse
(CharSequence
the CharSequence to parse.
csq
)

Parses the specified CharSequence to produce a Quantity.

Method Detail

formatback to summary
public Appendable format(Quantity<?> quantity, Appendable destination) throws IOException

Formats the specified quantity into an Appendable.

Parameters
quantity:Quantity<?>

the quantity to format.

destination:Appendable

the appendable destination.

Returns:Appendable

the specified Appendable.

Exceptions
IOException:
if an I/O exception occurs.
formatback to summary
public String format(Quantity<?> quantity)

Formats the specified Quantity.

Parameters
quantity:Quantity<?>

the Quantity to format, not null

Returns:String

the string representation using the settings of this QuantityFormat.

isLocaleSensitiveback to summary
public 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:boolean

whether this format depends on the locale.

parseback to summary
public Quantity<?> parse(CharSequence csq, ParsePosition pos) throws MeasurementParseException

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:CharSequence

the CharSequence to parse.

pos:ParsePosition

a ParsePosition object holding the current parsing index and error parsing index information as described above.

Returns:Quantity<?>

the quantity parsed from the specified character sub-sequence.

Exceptions
MeasurementParseException:
if any problem occurs while parsing the specified character sequence (e.g. illegal syntax).
parseback to summary
public Quantity<?> parse(CharSequence csq) throws MeasurementParseException

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:CharSequence

the CharSequence to parse.

Returns:Quantity<?>

the quantity parsed from the specified character sub-sequence.

Exceptions
MeasurementParseException:
if any problem occurs while parsing the specified character sequence (e.g. illegal syntax).