Package net.time4j.format
Class TimeSpanFormatter<U,S extends TimeSpan<U>>
java.lang.Object
net.time4j.format.TimeSpanFormatter<U,S>
- Type Parameters:
U
- generic type of time unitsS
- generic type of supported timespan
- Direct Known Subclasses:
Duration.Formatter
,MachineTime.Formatter
Represents a non-localized and user-defined format for timespans based on a pattern containing some standard symbols and literals.
- Since:
- 3.26/4.22
-
Method Summary
Modifier and TypeMethodDescriptionCreates a textual output of given duration.Yields the underlying format pattern.getType()
Yields the associated reified unit type.parse(CharSequence text)
Equivalent toparse(text, 0)
.parse(CharSequence text, int offset)
Analyzes given text according to format pattern and parses the text to a duration.void
print(TimeSpan<? super U> duration, Appendable buffer)
Creates a textual output of given duration and writes to the buffer.
-
Method Details
-
getPattern
Yields the underlying format pattern.
- Returns:
- String
-
getType
Yields the associated reified unit type.
- Returns:
- Class
-
format
Creates a textual output of given duration.
- Parameters:
duration
- duration object- Returns:
- textual representation of duration
- Throws:
IllegalArgumentException
- if some aspects of duration prevents printing (for example too many nanoseconds)
-
print
Creates a textual output of given duration and writes to the buffer.
- Parameters:
duration
- duration objectbuffer
- I/O-buffer where the result is written to- Throws:
IllegalArgumentException
- if some aspects of duration prevents printing (for example too many nanoseconds)IOException
- if writing into buffer fails
-
parse
Equivalent to
parse(text, 0)
.- Parameters:
text
- custom textual representation to be parsed- Returns:
- parsed duration
- Throws:
ParseException
- (for example in case of mixed signs or if trailing unparsed characters exist)- See Also:
parse(CharSequence, int)
-
parse
Analyzes given text according to format pattern and parses the text to a duration.
- Parameters:
text
- custom textual representation to be parsedoffset
- start position for the parser- Returns:
- parsed duration
- Throws:
ParseException
- (for example in case of mixed signs or if trailing unparsed characters exist)
-