public class NumberSpaceQuantityFormat extends AbstractQuantityFormat
Format.Field| Modifier and Type | Method and Description |
|---|---|
Appendable |
format(javax.measure.Quantity<?> quantity,
Appendable dest)
Formats the specified quantity into an
Appendable. |
static NumberSpaceQuantityFormat |
getInstance()
Returns the default format.
|
static NumberSpaceQuantityFormat |
getInstance(FormatBehavior style)
Returns the culture invariant format based upon
BigDecimal canonical
format and the standard unit format. |
static NumberSpaceQuantityFormat |
getInstance(NumberFormat numberFormat,
javax.measure.format.UnitFormat unitFormat)
Returns the quantity format using the specified number format and unit format
(the number and unit are separated by one space).
|
ComparableQuantity<?> |
parse(CharSequence csq)
Parses a portion of the specified
CharSequence from the specified position to produce an object. |
ComparableQuantity<?> |
parse(CharSequence csq,
ParsePosition cursor)
Parses a portion of the specified
CharSequence from the specified position to produce an object. |
format, format, parseObjectclone, format, formatToCharacterIterator, parseObjectpublic Appendable format(javax.measure.Quantity<?> quantity, Appendable dest) throws IOException
AbstractQuantityFormatAppendable.format in interface javax.measure.format.QuantityFormatformat in class AbstractQuantityFormatquantity - the quantity to format.dest - the appendable destination.Appendable.IOException - if an I/O exception occurs.public ComparableQuantity<?> parse(CharSequence csq, ParsePosition cursor) throws IllegalArgumentException, javax.measure.format.MeasurementParseException
AbstractQuantityFormatCharSequence 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.parse in interface javax.measure.format.QuantityFormatparse in class AbstractQuantityFormatcsq - the CharSequence to parse.cursor - the cursor holding the current parsing index.IllegalArgumentException - if any problem occurs while parsing the specified character sequence (e.g. illegal syntax).javax.measure.format.MeasurementParseExceptionpublic ComparableQuantity<?> parse(CharSequence csq) throws IllegalArgumentException, javax.measure.format.MeasurementParseException
AbstractQuantityFormatCharSequence 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.parse in interface javax.measure.format.QuantityFormatparse in interface tech.uom.lib.common.function.Parser<CharSequence,ComparableQuantity>parse in class AbstractQuantityFormatcsq - the CharSequence to parse.IllegalArgumentException - if any problem occurs while parsing the specified character sequence (e.g. illegal syntax).javax.measure.format.MeasurementParseExceptionpublic static NumberSpaceQuantityFormat getInstance(FormatBehavior style)
BigDecimal canonical
format and the standard unit format.
This format is not locale-sensitive and can be used for unambiguous
electronic communication of quantities together with their units without loss
of information. For example: "1.23456789 kg.m/s2" returns
Quantities.getQuantity(new BigDecimal("1.23456789"), AbstractUnit.parse("kg.m/s2")));style - the format style to apply.public static NumberSpaceQuantityFormat getInstance()
public static NumberSpaceQuantityFormat getInstance(NumberFormat numberFormat, javax.measure.format.UnitFormat unitFormat)
numberFormat - the number format.unitFormat - the unit format.Copyright © 2005–2018 Units of Measurement project. All rights reserved.