Serializable, Cloneablepublic class SimpleQuantityFormat extends AbstractQuantityFormat
Pattern letters are usually repeated, as their number determines the exact presentation:
Letter Quantity Component Presentation Examples nNumeric value Number 27uUnit Text m~Mixed radix Text 1 m; 27cm
"~" is followed by a character sequence acting as mixed radix delimiter. This character sequence must not contain "~" itself or any numeric values.Format.FieldDEFAULT_DELIMITER| Modifier | Constructor | Description |
|---|---|---|
protected |
SimpleQuantityFormat() |
Constructs a
SimpleQuantityFormat using the default pattern. |
|
SimpleQuantityFormat(String pattern) |
Constructs a
SimpleQuantityFormat using the given pattern. |
| Modifier and Type | Method | Description |
|---|---|---|
Appendable |
format(javax.measure.Quantity<?> quantity,
Appendable dest) |
Formats the specified quantity into an
Appendable. |
protected StringBuffer |
formatMixed(MixedQuantity<?> mixed,
StringBuffer dest) |
Convenience method equivalent to
#format(MixedQuantity, Appendable) except it does not raise an IOException. |
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() |
|
javax.measure.Quantity<?> |
parse(CharSequence csq) |
Parses a portion of the specified
CharSequence from the specified position to produce an object. |
protected javax.measure.Quantity<?> |
parse(CharSequence csq,
int index) |
Parses a portion of the specified
CharSequence from the specified position to produce an object. |
javax.measure.Quantity<?> |
parse(CharSequence csq,
ParsePosition cursor) |
Parses a portion of the specified
CharSequence from the specified position to produce an object. |
String |
toString() |
format, 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 invalidprotected 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 class AbstractQuantityFormatquantity - the quantity to format.dest - the appendable destination.Appendable.IOException - if an I/O exception occurs.public javax.measure.Quantity<?> 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 class AbstractQuantityFormatcsq - the CharSequence to parse.cursor - the cursor holding the current parsing index.javax.measure.format.MeasurementParseExceptionprotected javax.measure.Quantity<?> parse(CharSequence csq, int index) 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 class AbstractQuantityFormatcsq - the CharSequence to parse.index - the current parsing index.javax.measure.format.MeasurementParseExceptionpublic javax.measure.Quantity<?> 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 class AbstractQuantityFormatcsq - the CharSequence to parse.javax.measure.format.MeasurementParseExceptionpublic static SimpleQuantityFormat getInstance()
Unit
separated by whitespace(s).SimpleQuantityFormat instance.public static SimpleQuantityFormat getInstance(String pattern)
SimpleQuantityFormat using the given pattern.
pattern - the pattern describing the quantity and unit formatSimpleQuantityFormat.getInstance(a pattern)public String getPattern()
protected StringBuffer formatMixed(MixedQuantity<?> mixed, StringBuffer dest)
AbstractQuantityFormat#format(MixedQuantity, Appendable) except it does not raise an IOException.formatMixed in class AbstractQuantityFormatmixed - the mixed quantity to format.dest - the appendable destination.StringBuilder.Copyright © 2005–2023 Units of Measurement project. All rights reserved.