U - generic type of time unitsS - generic type of supported timespanpublic abstract class TimeSpanFormatter<U,S extends TimeSpan<U>> extends 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 |
|---|---|
String |
format(TimeSpan<? super U> duration)
Creates a textual output of given duration.
|
String |
getPattern()
Yields the underlying format pattern.
|
Class<U> |
getType()
Yields the associated reified unit type.
|
S |
parse(CharSequence text)
Equivalent to
parse(text, 0). |
S |
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.
|
public String getPattern()
Yields the underlying format pattern.
public String format(TimeSpan<? super U> duration)
Creates a textual output of given duration.
duration - duration objectIllegalArgumentException - if some aspects of duration
prevents printing (for example too many nanoseconds)public void print(TimeSpan<? super U> duration, Appendable buffer) throws IOException
Creates a textual output of given duration and writes to the buffer.
duration - duration objectbuffer - I/O-buffer where the result is written toIllegalArgumentException - if some aspects of duration
prevents printing (for example too many nanoseconds)IOException - if writing into buffer failspublic S parse(CharSequence text) throws ParseException
Equivalent to parse(text, 0).
text - custom textual representation to be parsedParseException - (for example in case of mixed signs or if trailing unparsed characters exist)parse(CharSequence, int)public S parse(CharSequence text, int offset) throws 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 parserParseException - (for example in case of mixed signs or if trailing unparsed characters exist)Copyright © 2014–2017. All rights reserved.