Effective in 2026, to align with our trunk stable development model and ensure platform stability for the ecosystem, we will publish source code to AOSP in Q2 and Q4. For building and contributing to AOSP, use android-latest-release. The android-latest-release manifest branch will always reference the most recent release pushed to AOSP. For more information, see Changes to AOSP.
Stay organized with collections
Save and categorize content based on your preferences.
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.
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 constructors
TimeVal
public TimeVal (Long value)
Constructs a newly allocated TimeVal object that represents the specified Long argument
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.
| Throws |
NumberFormatException |
|
Public methods
asLong
public Long asLong ()
| Returns |
Long |
the wrapped Long value. |
compareTo
public int compareTo (Long other)
doubleValue
public double doubleValue ()
floatValue
public float floatValue ()
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.
| Throws |
NumberFormatException |
|
intValue
public int intValue ()
longValue
public long longValue ()
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2026-06-22 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-06-22 UTC."],[],[]]