Package org.apache.sis.measure
Class QuantityFormat
- All Implemented Interfaces:
- Serializable,- Cloneable
Parses and formats numbers with units of measurement.
- Since:
- 1.1
- See Also:
Defined in the sis-utility module
- 
Nested Class SummaryNested classes/interfaces inherited from class FormatFormat.Field
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final NumberFormatThe format for parsing and formatting the number part.static final charThe default separator used between numerical value and its unit of measurement.protected final UnitFormatThe format for parsing and formatting the unit of measurement part.
- 
Constructor SummaryConstructorsConstructorDescriptionQuantityFormat(NumberFormat numberFormat, UnitFormat unitFormat) Creates a new instance using the given number and unit formats.QuantityFormat(Locale locale) Creates a new instance for the given locale.
- 
Method SummaryModifier and TypeMethodDescriptionclone()Returns a clone of this format.format(Object quantity, StringBuffer toAppendTo, FieldPosition pos) Formats the specified quantity in the given buffer.parseObject(String source, ParsePosition pos) Parses text from a string to produce a quantity, or returnsnullif the parsing failed.Methods inherited from class Formatformat, formatToCharacterIterator, parseObject
- 
Field Details- 
SEPARATORpublic static final char SEPARATORThe default separator used between numerical value and its unit of measurement. Current value is narrow no-break space (U+202F).- See Also:
 
- 
numberFormatThe format for parsing and formatting the number part.
- 
unitFormatThe format for parsing and formatting the unit of measurement part.
 
- 
- 
Constructor Details- 
QuantityFormatCreates a new instance for the given locale.- Parameters:
- locale- the locale for the quantity format.
 
- 
QuantityFormatCreates a new instance using the given number and unit formats.- Parameters:
- numberFormat- the format for parsing and formatting the number part.
- unitFormat- the format for parsing and formatting the unit of measurement part.
 
 
- 
- 
Method Details- 
formatFormats the specified quantity in the given buffer. The given object shall be aQuantityinstance.
- 
parseObjectParses text from a string to produce a quantity, or returnsnullif the parsing failed.- Specified by:
- parseObjectin class- Format
- Parameters:
- source- the text, part of which should be parsed.
- pos- index and error index information.
- Returns:
- a quantity parsed from the string, or nullin case of error.
 
- 
cloneReturns a clone of this format.
 
-