TimeVal

public class TimeVal
extends Number implements Comparable<Long>

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


這是包裝 Long 的信號類型。這個值僅做為選項剖析機制的提示,指出特定值應剖析為代表時間值的字串。

建議改用 Duration

摘要

公用建構函式

TimeVal(Long value)

建構新分配的 TimeVal 物件,代表指定的 Long 引數

TimeVal(String value)

建構新分配的 TimeVal 物件,代表 String 參數所指出的時間戳記

公用方法

Long asLong()
int compareTo(Long other)

double doubleValue()

float floatValue()

static long fromString(String value)

將字串剖析為階層式時間值

預設單位為毫秒。

int intValue()

long longValue()

公用建構函式

TimeVal

public TimeVal (Long value)

建構新分配的 TimeVal 物件,代表指定的 Long 引數

參數
value Long

TimeVal

public TimeVal (String value)

建構新分配的 TimeVal 物件,代表 String 參數所指出的時間戳記。字串會以 fromString(String) 方法使用的確切方式轉換為 TimeVal。

參數
value String

擲回
NumberFormatException

公用方法

asLong

public Long asLong ()

傳回
Long 包裝的 Long 值。

compareTo

public int compareTo (Long other)

參數
other Long

傳回
int

doubleValue

public double doubleValue ()

傳回
double

floatValue

public float floatValue ()

傳回
float

fromString

public static long fromString (String value)

將字串剖析為階層式時間值

預設單位為毫秒。剖析器會接受 s 代表秒 (1000 毫秒)、m 代表分鐘 (60 秒)、h 代表小時 (60 分鐘),或 d 代表天 (24 小時)。

只要每個單位最多出現一次,且所有出現的單位都依比例遞減順序排列,即可混用單位。舉例來說,h 可能只會出現在 m 之前,也可能只會出現在 d 之後。舉例來說,「1d2h3m4s5ms」是有效時間值,「4」或「4ms」也是。系統會捨棄所有內嵌的空白字元。

請注意,這個方法會拒絕溢位。因此輸出數字保證為非負數,且符合 long 型別。

參數
value String

傳回
long

擲回
NumberFormatException

intValue

public int intValue ()

傳回
int

longValue

public long longValue ()

傳回
long