GO語言"time"包中"Duration.String"類型的用法及代碼示例。
用法:
func(d Duration) String() string
String 返回一個表示持續時間的字符串,格式為 "72h3m0.5s"。前導零單元被省略。作為一種特殊情況,小於一秒的持續時間格式使用更小的單位(毫秒、微秒或納秒)來確保前導數字不為零。零持續時間格式為 0。
例子:
package main
import (
"fmt"
"time"
)
func main() {
fmt.Println(1*time.Hour + 2*time.Minute + 300*time.Millisecond)
fmt.Println(300 * time.Millisecond)
}
輸出:
1h2m0.3s 300ms
相關用法
- GO Duration.Seconds用法及代碼示例
- GO Duration.Hours用法及代碼示例
- GO Duration.Round用法及代碼示例
- GO Duration.Truncate用法及代碼示例
- GO Duration.Minutes用法及代碼示例
- GO Duration.Milliseconds用法及代碼示例
- GO Duration.Microseconds用法及代碼示例
- GO Duration.Nanoseconds用法及代碼示例
- GO Duration用法及代碼示例
- GO DumpResponse用法及代碼示例
- GO DumpRequest用法及代碼示例
- GO DumpRequestOut用法及代碼示例
- GO Dumper用法及代碼示例
- GO Dump用法及代碼示例
- GO DecodeLastRuneInString用法及代碼示例
- GO DB.QueryRowContext用法及代碼示例
- GO Date用法及代碼示例
- GO DB.ExecContext用法及代碼示例
- GO Dial用法及代碼示例
- GO DB.BeginTx用法及代碼示例
注:本文由純淨天空篩選整理自golang.google.cn大神的英文原創作品 Duration.String。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。