TimeVal

public class TimeVal
extends Number implements Comparable<Long>

java.lang.Object
   ↳ java.lang.Number
     ↳ com.android.tradefed.util.TimeVal


This is a sentinel type which wraps a Long. It exists solely as a hint to the options parsing machinery that a particular value should be parsed as if it were a string representing a time value.

Summary

Public constructors

TimeVal(Long value)

Constructs a newly allocated TimeVal object that represents the specified Long argument

TimeVal(String value)

Constructs a newly allocated TimeVal object that represents the timestamp indicated by the String parameter.

Public methods

Long asLong()
int compareTo(Long other)

double doubleValue()

float floatValue()

static long fromString(String value)

Parses the string as a hierarchical time value

The default unit is millis.

int intValue()

long longValue()

Public constructors

TimeVal

TimeVal (Long value)

Constructs a newly allocated TimeVal object that represents the specified Long argument

Parameters
value Long

TimeVal

TimeVal (String value)

Constructs a newly allocated TimeVal object that represents the timestamp indicated by the String parameter. The string is converted to a TimeVal in exactly the manner used by the fromString(String) method.

Parameters
value String
Throws
NumberFormatException

Public methods

asLong

Long asLong ()

Returns
Long the wrapped Long value.

compareTo

int compareTo (Long other)

Parameters
other Long
Returns
int

doubleValue

double doubleValue ()

Returns
double

floatValue

float floatValue ()

Returns
float

fromString

long fromString (String value)

Parses the string as a hierarchical time value

The default unit is millis. The parser will accept s for seconds (1000 millis), m for minutes (60 seconds), h for hours (60 minutes), or d for days (24 hours).

Units may be mixed and matched, so long as each unit appears at most once, and so long as all units which do appear are listed in decreasing order of scale. So, for instance, h may only appear before m, and may only appear after d. As a specific example, "1d2h3m4s5ms" would be a valid time value, as would "4" or "4ms". All embedded whitespace is discarded.

Do note that this method rejects overflows. So the output number is guaranteed to be non-negative, and to fit within the long type.

Parameters
value String
Returns
long
Throws
NumberFormatException

intValue

int intValue ()

Returns
int

longValue

long longValue ()

Returns
long