public class SimpleQuantityFormat extends AbstractQuantityFormat
Format.Field| Constructor and Description |
|---|
SimpleQuantityFormat()
Constructs a
SimpleQuantityFormat using the default pattern. |
SimpleQuantityFormat(String pattern)
Constructs a
SimpleQuantityFormat using the given pattern. |
| Modifier and Type | Method and Description |
|---|---|
Appendable |
format(javax.measure.Quantity quantity,
Appendable dest)
Formats the specified quantity into an
Appendable. |
static SimpleQuantityFormat |
getInstance()
Returns the quantity format for the default locale.
|
static SimpleQuantityFormat |
getInstance(String pattern)
Returns a
SimpleQuantityFormat using the given pattern. |
String |
getPattern() |
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 SimpleQuantityFormat(String pattern)
SimpleQuantityFormat using the given pattern.
pattern - the pattern describing the quantity and unit formatNullPointerException - if the given pattern is nullIllegalArgumentException - if the given pattern is invalidpublic SimpleQuantityFormat()
SimpleQuantityFormat using the default pattern. For
full coverage, use the factory methods.public 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 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.javax.measure.format.MeasurementParseExceptionpublic ComparableQuantity<?> parse(CharSequence csq) throws 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.javax.measure.format.MeasurementParseExceptionpublic static SimpleQuantityFormat getInstance()
Unit
separated by whitespace(s).MeasureFormat.getInstance(NumberFormat.getInstance(), UnitFormat.getInstance())public static SimpleQuantityFormat getInstance(String pattern)
SimpleQuantityFormat using the given pattern.
pattern - the pattern describing the quantity and unit formatMeasureFormat.getInstance(NumberFormat.getInstance(), UnitFormat.getInstance())public String getPattern()
Copyright © 2005–2018 Units of Measurement project. All rights reserved.