TimeVal
public
class
TimeVal
extends Object
| java.lang.Object | |
| ↳ | 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 物件,代表字串參數所指示的fromString(String) 方法使用的確切方式轉換為 TimeVal。
| 參數 | |
|---|---|
value |
String |
公用方法
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 |
|
intValue
public int intValue ()
| 傳回 | |
|---|---|
int |
|
longValue
public long longValue ()
| 傳回 | |
|---|---|
long |
|