TimeVal

public class TimeVal
extends Object

java.lang.Object
   ↳ 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.

We recommend using Duration instead.

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

public TimeVal (Long value)

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

Parameters
value Long

TimeVal

public 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

Public methods

asLong

public Long asLong ()

Returns
Long the wrapped Long value.

compareTo

public int compareTo (Long other)

Parameters
other Long

Returns
int

doubleValue

public double doubleValue ()

Returns
double

floatValue

public float floatValue ()

Returns
float

fromString

public static 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

intValue

public int intValue ()

Returns
int

longValue

public long longValue ()

Returns
long