U - generic type of time unitsS - generic type of supported timespanpublic abstract class TimeSpanFormatter<U,S extends TimeSpan<U>>
extends java.lang.Object
Represents a non-localized and user-defined format for timespans based on a pattern containing some standard symbols and literals.
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
format(TimeSpan<? super U> duration)
Creates a textual output of given duration.
|
java.lang.String |
getPattern()
Yields the underlying format pattern.
|
java.lang.Class<U> |
getType()
Yields the associated reified unit type.
|
S |
parse(java.lang.CharSequence text)
Equivalent to
parse(text, 0). |
S |
parse(java.lang.CharSequence text,
int offset)
Analyzes given text according to format pattern and parses the
text to a duration.
|
void |
print(TimeSpan<? super U> duration,
java.lang.Appendable buffer)
Creates a textual output of given duration and writes to
the buffer.
|
public java.lang.String getPattern()
Yields the underlying format pattern.
public java.lang.Class<U> getType()
Yields the associated reified unit type.
public java.lang.String format(TimeSpan<? super U> duration)
Creates a textual output of given duration.
duration - duration objectjava.lang.IllegalArgumentException - if some aspects of duration
prevents printing (for example too many nanoseconds)public void print(TimeSpan<? super U> duration, java.lang.Appendable buffer) throws java.io.IOException
Creates a textual output of given duration and writes to the buffer.
duration - duration objectbuffer - I/O-buffer where the result is written tojava.lang.IllegalArgumentException - if some aspects of duration
prevents printing (for example too many nanoseconds)java.io.IOException - if writing into buffer failspublic S parse(java.lang.CharSequence text) throws java.text.ParseException
Equivalent to parse(text, 0).
text - custom textual representation to be parsedjava.text.ParseException - (for example in case of mixed signs)parse(CharSequence, int)public S parse(java.lang.CharSequence text, int offset) throws java.text.ParseException
Analyzes given text according to format pattern and parses the text to a duration.
text - custom textual representation to be parsedoffset - start position for the parserjava.text.ParseException - (for example in case of mixed signs)