public class SecondDurationParser extends java.lang.Object implements ValueParser<java.lang.Integer>
A parser for identifying durations specified in a particular format. The duration is converted into a number (a long) representing the number of seconds of the duration.
The format must be either HHmmss or HH:mm:ss where H is the number of hours, m is the number of minutes and s is the number of seconds. If the format contains colons, the hour, minute and second fields can contain values with more or less than two digits. For example these formats are legal:
000001 - one second
100101 - ten hours one minute one second
10:01:01 - ten hours one minute one second
100:5:16 - one hundred hours five minutes sixteen seconds
120:05:21 - one hundred and twenty hours five minutes twenty one seconds
However, if colons aren't present, the string must be exactly six characters long with the first two characters representing hours, the second two representing minutes and the third two representing seconds.
| Modifier and Type | Field and Description |
|---|---|
static SecondDurationParser |
PARSER |
| Constructor and Description |
|---|
SecondDurationParser() |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
format(java.lang.Integer value)
Format a value as a string.
|
java.lang.Class<java.lang.Integer> |
getType()
Returns the
Class of object this ValueParser can handle. |
java.lang.Integer |
parse(java.lang.String valueString)
Parses the specified string and constructs the appropriate object out of
it.
|
public static final SecondDurationParser PARSER
public java.lang.Class<java.lang.Integer> getType()
ValueParserClass of object this ValueParser can handle.
The ValueParser.parse(String) method must return objects that are assignable to this type.
The #format(T) method can format any object assignable to this type.
The returned class will be the
exact Class (i.e. not a subclass) of this
ValueParser's typegetType in interface ValueFormatter<java.lang.Integer>getType in interface ValueParser<java.lang.Integer>ValueParserpublic java.lang.Integer parse(java.lang.String valueString)
throws java.lang.IllegalArgumentException,
java.lang.NullPointerException
ValueParserparse in interface ValueParser<java.lang.Integer>java.lang.IllegalArgumentExceptionjava.lang.NullPointerExceptionvalueString - The string to parsevalueStringpublic java.lang.String format(java.lang.Integer value)
ValueParserformat in interface ValueFormatter<java.lang.Integer>format in interface ValueParser<java.lang.Integer>value - The object to format